Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -94,7 +94,7 @@ public abstract class AbstractCodeModel
*
* @param nameProvider the {@link NameProvider}
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
protected AbstractCodeModel(final NameProvider nameProvider) {

this.nameProvider = Objects.requireNonNull(nameProvider, "The NameProvider must not be null");
Expand Down Expand Up @@ -126,11 +126,11 @@ protected AbstractCodeModel(final NameProvider nameProvider) {
* @param namespaceDescriptors the {@link Stream} of {@link Marshalled} {@link NamespaceDescriptor}s
*/
protected AbstractCodeModel(final NameProvider nameProvider,
final Marshaller marshaller,
final Stream<Marshalled<Trait>> traits,
final Stream<Marshalled<TypeDescriptor>> typeDescriptors,
final Stream<Marshalled<ModuleDescriptor>> moduleDescriptors,
final Stream<Marshalled<NamespaceDescriptor>> namespaceDescriptors) {
final Marshaller marshaller,
final Stream<Marshalled<Trait>> traits,
final Stream<Marshalled<TypeDescriptor>> typeDescriptors,
final Stream<Marshalled<ModuleDescriptor>> moduleDescriptors,
final Stream<Marshalled<NamespaceDescriptor>> namespaceDescriptors) {

this(nameProvider);

Expand Down Expand Up @@ -245,20 +245,15 @@ public <T> Iterator<T> iterator(final Class<T> type) {
this.moduleDescriptors.values().iterator(),
this.namespaceDescriptors.values().iterator(),
this.traitable.iterator(type));
}
else if (CodeModel.class.isAssignableFrom(type)) {
} else if (CodeModel.class.isAssignableFrom(type)) {
return (Iterator<T>) Iterators.of(this);
}
else if (TypeDescriptor.class.isAssignableFrom(type)) {
} else if (TypeDescriptor.class.isAssignableFrom(type)) {
return (Iterator<T>) this.typeDescriptors.values().iterator();
}
else if (ModuleDescriptor.class.isAssignableFrom(type)) {
} else if (ModuleDescriptor.class.isAssignableFrom(type)) {
return (Iterator<T>) this.moduleDescriptors.values().iterator();
}
else if (NamespaceDescriptor.class.isAssignableFrom(type)) {
} else if (NamespaceDescriptor.class.isAssignableFrom(type)) {
return (Iterator<T>) this.namespaceDescriptors.values().iterator();
}
else {
} else {
return this.traitable.iterator(type);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -104,7 +104,8 @@ default TypeDescriptor createTypeDescriptor(final TypeName typeName) {
*/
default <T extends TypeDescriptor> T createTypeDescriptor(final TypeName typeName,
final BiFunction<? super CodeModel, ? super TypeName, T> supplier) {
return createTypeDescriptor(typeName, supplier, t -> {});
return createTypeDescriptor(typeName, supplier, t -> {
});
}

/**
Expand Down Expand Up @@ -234,7 +235,8 @@ default ModuleDescriptor createModuleDescriptor(final ModuleName moduleName) {
*/
default <M extends ModuleDescriptor> M createModuleDescriptor(final ModuleName moduleName,
final BiFunction<? super CodeModel, ? super ModuleName, M> supplier) {
return createModuleDescriptor(moduleName, supplier, m -> {});
return createModuleDescriptor(moduleName, supplier, m -> {
});
}

/**
Expand Down Expand Up @@ -321,7 +323,8 @@ default NamespaceDescriptor createNamespaceDescriptor(final Namespace namespace)
*/
default <N extends NamespaceDescriptor> N createNamespaceDescriptor(final Namespace namespace,
final BiFunction<? super CodeModel, ? super Namespace, N> supplier) {
return createNamespaceDescriptor(namespace, supplier, n -> {});
return createNamespaceDescriptor(namespace, supplier, n -> {
});
}

/**
Expand Down Expand Up @@ -360,7 +363,8 @@ default <N extends NamespaceDescriptor> N createNamespaceDescriptor(final Namesp
* @return the new {@link Traitable} for the {@link Object} in the {@link CodeModel}
*/
default Traitable createTraitable(final Traitable object) {
return createTraitable(object, t -> {});
return createTraitable(object, t -> {
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -89,10 +89,10 @@ class CodeModelTraitable
* Constructs a {@link CodeModelTraitable} for the specified {@link Object}.
*
* @param codeModel the {@link AbstractCodeModel} that established the {@link Traitable}
* @param object the {@link Traitable} {@link Object}
* @param object the {@link Traitable} {@link Object}
*/
CodeModelTraitable(final AbstractCodeModel codeModel,
final Traitable object) {
final Traitable object) {

this.codeModel = Objects.requireNonNull(codeModel, "The CodeModel must not be null");
this.object = Objects.requireNonNull(object, "The object must not be null");
Expand Down Expand Up @@ -165,8 +165,7 @@ public <C extends Traitable, T extends Trait> T createTrait(final Function<C, T>
this.codeModel.index().index(trait);
return trait;
});
}
else {
} else {
this.traitsByClass.compute(registrationClass, (_, existing) -> {
final var list = existing == null ? ConcurrentHashMap.<Trait>newKeySet() : existing;

Expand Down Expand Up @@ -216,13 +215,11 @@ public <T extends Trait> boolean removeTrait(final T trait) {

removed.set(true);
return null;
}
else {
} else {
return existing;
}
});
}
else {
} else {
this.traitsByClass.compute(registrationClass, (_, existing) -> {
if (existing == null) {
removed.set(false);
Expand All @@ -236,8 +233,7 @@ public <T extends Trait> boolean removeTrait(final T trait) {
traitAware.onRemovedTrait(trait);
}
removed.set(true);
}
else {
} else {
removed.set(false);
}

Expand Down Expand Up @@ -278,15 +274,13 @@ public <C extends Traitable, T extends Trait> Optional<T> computeIfAbsent(final

this.codeModel.index().index(newTrait);
return newTrait;
}
else {
} else {
lazyTrait.set((T) existing);

return existing;
}
});
}
else {
} else {
this.traitsByClass.compute(registrationClass, (_, existing) -> {
if (existing == null || existing.isEmpty()) {
final var trait = function.apply(traitable);
Expand Down Expand Up @@ -363,8 +357,7 @@ public <C extends Traitable, T extends Trait> Optional<T> computeIfPresent(final

return newTrait;
});
}
else {
} else {
this.traitsByClass.compute(registrationClass, (_, existing) -> {
if (existing == null || existing.isEmpty()) {
return existing;
Expand Down Expand Up @@ -499,8 +492,7 @@ private <T> T getTraitOrNull(final Class<T> requiredClass)

final var first = (T) traits.iterator().next();
return requiredClass.isInstance(first) ? first : null;
}
else {
} else {
// exhaustively search :(
return this.singularTraitsByClass.values().stream()
.filter(requiredClass::isInstance)
Expand Down Expand Up @@ -581,9 +573,9 @@ public String toString() {
return this.traitsByClass.isEmpty()
? ""
: this.traitsByClass.values().stream()
.flatMap(Set::stream)
.map(Object::toString)
.collect(Collectors.joining(",", " [", "]"));
.flatMap(Set::stream)
.map(Object::toString)
.collect(Collectors.joining(",", " [", "]"));
}

/**
Expand All @@ -596,16 +588,14 @@ public String toString() {
public static boolean isSingular(final Class<? extends Trait> registrationClass) {
if (singularTraitClasses.contains(registrationClass)) {
return true;
}
else if (nonSingularTraitClasses.contains(registrationClass)) {
} else if (nonSingularTraitClasses.contains(registrationClass)) {
return false;
}

final var singular = registrationClass.getAnnotation(Singular.class);
if (singular == null) {
nonSingularTraitClasses.add(registrationClass);
}
else {
} else {
singularTraitClasses.add(registrationClass);
}

Expand Down Expand Up @@ -686,8 +676,7 @@ && isConcrete(registrationClass)) {
for (final Class<?> interfaceClass : registrationClass.getInterfaces()) {
hierarchy.push(interfaceClass);
}
}
else {
} else {
// ensure that the registration class is a Trait
if (Trait.class.isAssignableFrom(registrationClass)) {

Expand All @@ -704,8 +693,7 @@ && isConcrete(registrationClass)) {
}

return (Class<? extends Trait>) registrationClass;
}
else {
} else {
// we ignore classes that use @Singular or @NonSingular which are not Traits
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -68,11 +68,11 @@ public ConceptualCodeModel(final NameProvider nameProvider) {
*/
@Unmarshal
public ConceptualCodeModel(final @Bound NameProvider nameProvider,
final Marshaller marshaller,
final Stream<Marshalled<Trait>> traits,
final Stream<Marshalled<TypeDescriptor>> typeDescriptors,
final Stream<Marshalled<ModuleDescriptor>> moduleDescriptors,
final Stream<Marshalled<NamespaceDescriptor>> namespaceDescriptors) {
final Marshaller marshaller,
final Stream<Marshalled<Trait>> traits,
final Stream<Marshalled<TypeDescriptor>> typeDescriptors,
final Stream<Marshalled<ModuleDescriptor>> moduleDescriptors,
final Stream<Marshalled<NamespaceDescriptor>> namespaceDescriptors) {

super(nameProvider, marshaller, traits, typeDescriptors, moduleDescriptors, namespaceDescriptors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -49,7 +49,7 @@ public abstract class AbstractModuleDescriptor
/**
* Constructs an {@link AbstractModuleDescriptor}.
*
* @param codeModel the {@link CodeModel}
* @param codeModel the {@link CodeModel}
* @param moduleName the {@link ModuleName}
*/
protected AbstractModuleDescriptor(final CodeModel codeModel,
Expand All @@ -63,7 +63,7 @@ protected AbstractModuleDescriptor(final CodeModel codeModel,
/**
* {@link Unmarshal} an {@link AbstractModuleDescriptor}.
*
* @param codeModel the {@link CodeModel}
* @param codeModel the {@link CodeModel}
* @param marshaller the {@link Marshaller} for unmarshalling the {@link Marshalled} {@link Trait}s
* @param moduleName the {@link ModuleName}
* @param traits the {@link Marshalled} {@link Trait}s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -50,7 +50,7 @@ public abstract class AbstractNamespaceDescriptor
* Constructs an {@link AbstractNamespaceDescriptor}.
*
* @param codeModel the {@link CodeModel}
* @param namespace the {@link Namespace}
* @param namespace the {@link Namespace}
*/
protected AbstractNamespaceDescriptor(final CodeModel codeModel,
final Namespace namespace) {
Expand All @@ -63,7 +63,7 @@ protected AbstractNamespaceDescriptor(final CodeModel codeModel,
/**
* {@link Unmarshal} an {@link AbstractNamespaceDescriptor}.
*
* @param codeModel the {@link CodeModel}
* @param codeModel the {@link CodeModel}
* @param marshaller the {@link Marshaller} for unmarshalling the {@link Marshalled} {@link Trait}s
* @param namespace the {@link Namespace}
* @param traits the {@link Marshalled} {@link Trait}s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -75,13 +75,13 @@ protected AbstractTraitable(final Traitable traitable) {
this(traitable instanceof CodeModel self
? self
: Objects.requireNonNull(traitable, "The Traitable must not be null")
.codeModel());
.codeModel());
}

/**
* {@link Unmarshal} an {@link AbstractTraitable}.
*
* @param codeModel the {@link CodeModel}
* @param codeModel the {@link CodeModel}
* @param marshaller the {@link Marshaller} for unmarshalling the {@link Marshalled} {@link Trait}s
* @param traits the {@link Marshalled} {@link Trait}s
*/
Expand Down Expand Up @@ -113,8 +113,7 @@ protected void destructor(final Marshaller marshaller,
traits.set(traits()
.filter(trait -> marshaller.isMarshallable(trait.getClass()))
.map(marshaller::marshal));
}
else {
} else {
traits.set(Stream.empty());
}
}
Expand Down
Loading