private Optional<StyleInfo> determineStyle() { if (declaringType().isPresent()) { DeclaringType type = declaringType().get(); Optional<DeclaringType> enclosing = type.enclosingOf(); if (enclosing.isPresent()) { if (enclosing.get() != type) { Optional<StyleInfo> style = type.style(); if (style.isPresent()) { warnAboutIncompatibleStyles(); } } Optional<StyleInfo> enclosingStyle = enclosing.get().style(); if (enclosingStyle.isPresent()) { return enclosingStyle; } } else { Optional<StyleInfo> style = type.style(); if (style.isPresent()) { return style; } Optional<DeclaringType> topLevel = type.enclosingTopLevel(); if (topLevel.isPresent() && topLevel.get().style().isPresent()) { return topLevel.get().style(); } } } return packageOf().style(); }