Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: David Kral <david.k.kral@oracle.com>
  • Loading branch information
Verdent committed Aug 15, 2023
1 parent 1c61b23 commit 76afdca
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Set;
import java.util.function.Predicate;

import io.helidon.common.processor.model.ClassModel;
import io.helidon.common.processor.model.Field;
import io.helidon.common.processor.model.InnerClass;
import io.helidon.common.processor.model.Javadoc;
Expand Down
5 changes: 2 additions & 3 deletions common/processor/class-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.common.processor</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public abstract static class Builder<B extends Builder<B, T>, T extends ClassBas
extends AnnotatedComponent.Builder<B, T> {

private final Set<Method> methods = new LinkedHashSet<>();
private final Set<Method> staticMethods = new HashSet<>();
private final Set<Method> staticMethods = new LinkedHashSet<>();
private final Set<Type> interfaces = new LinkedHashSet<>();
private final Map<String, Field> fields = new LinkedHashMap<>();
private final Map<String, Field> staticFields = new LinkedHashMap<>();
Expand Down
62 changes: 31 additions & 31 deletions common/types/src/main/java/io/helidon/common/types/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public interface Annotation extends AnnotationBlueprint, Prototype.Api, Comparab
*
* @return a new builder
*/
static Builder builder() {
return new Builder();
static Annotation.Builder builder() {
return new Annotation.Builder();
}

/**
Expand All @@ -50,10 +50,30 @@ static Builder builder() {
* @param instance an existing instance used as a base for the builder
* @return a builder based on an instance
*/
static Builder builder(Annotation instance) {
static Annotation.Builder builder(Annotation instance) {
return Annotation.builder().from(instance);
}

/**
* Creates an instance for an annotation with no value.
*
* @param annoType the annotation type
* @return the new instance
*/
static Annotation create(Class<? extends java.lang.annotation.Annotation> annoType) {
return AnnotationSupport.create(annoType);
}

/**
* Creates an instance for an annotation with no value.
*
* @param annoType the annotation type
* @return the new instance
*/
static Annotation create(TypeName annoType) {
return AnnotationSupport.create(annoType);
}

/**
* Creates an instance for an annotation with a value.
*
Expand Down Expand Up @@ -98,33 +118,13 @@ static Annotation create(TypeName annoTypeName, Map<String, String> values) {
return AnnotationSupport.create(annoTypeName, values);
}

/**
* Creates an instance for an annotation with no value.
*
* @param annoType the annotation type
* @return the new instance
*/
static Annotation create(Class<? extends java.lang.annotation.Annotation> annoType) {
return AnnotationSupport.create(annoType);
}

/**
* Creates an instance for an annotation with no value.
*
* @param annoType the annotation type
* @return the new instance
*/
static Annotation create(TypeName annoType) {
return AnnotationSupport.create(annoType);
}

/**
* Fluent API builder base for {@link Annotation}.
*
* @param <BUILDER> type of the builder extending this abstract builder
* @param <PROTOTYPE> type of the prototype interface that would be built by {@link #buildPrototype()}
*/
abstract class BuilderBase<BUILDER extends BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends Annotation> implements Prototype.Builder<BUILDER, PROTOTYPE> {
abstract class BuilderBase<BUILDER extends Annotation.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends Annotation> implements Prototype.Builder<BUILDER, PROTOTYPE> {

private final Map<String, String> values = new LinkedHashMap<>();
private TypeName typeName;
Expand Down Expand Up @@ -153,7 +153,7 @@ public BUILDER from(Annotation prototype) {
* @param builder existing builder prototype to update this builder from
* @return updated builder instance
*/
public BUILDER from(BuilderBase<?, ?> builder) {
public BUILDER from(Annotation.BuilderBase<?, ?> builder) {
builder.typeName().ifPresent(this::typeName);
addValues(builder.values());
return self();
Expand Down Expand Up @@ -182,7 +182,7 @@ public BUILDER value(String value) {
}

/**
* The type name, e.g., {@link Objects} -> "java.util.Objects".
* The type name, e.g., {@link java.util.Objects} -> "java.util.Objects".
*
* @param typeName the annotation type name
* @return updated builder instance
Expand All @@ -195,7 +195,7 @@ public BUILDER typeName(TypeName typeName) {
}

/**
* The type name, e.g., {@link Objects} -> "java.util.Objects".
* The type name, e.g., {@link java.util.Objects} -> "java.util.Objects".
*
* @param consumer consumer of builder for
* the annotation type name
Expand All @@ -211,7 +211,7 @@ public BUILDER typeName(Consumer<TypeName.Builder> consumer) {
}

/**
* The type name, e.g., {@link Objects} -> "java.util.Objects".
* The type name, e.g., {@link java.util.Objects} -> "java.util.Objects".
*
* @param supplier supplier of
* the annotation type name
Expand Down Expand Up @@ -267,7 +267,7 @@ public BUILDER putValue(String key, String value) {
}

/**
* The type name, e.g., {@link Objects} -> "java.util.Objects".
* The type name, e.g., {@link java.util.Objects} -> "java.util.Objects".
*
* @return the type name
*/
Expand Down Expand Up @@ -322,7 +322,7 @@ protected static class AnnotationImpl implements Annotation {
*
* @param builder extending builder base of this prototype
*/
protected AnnotationImpl(BuilderBase<?, ?> builder) {
protected AnnotationImpl(Annotation.BuilderBase<?, ?> builder) {
this.typeName = builder.typeName().get();
this.values = Collections.unmodifiableMap(new LinkedHashMap<>(builder.values()));
}
Expand Down Expand Up @@ -374,7 +374,7 @@ public int hashCode() {
/**
* Fluent API builder for {@link Annotation}.
*/
class Builder extends BuilderBase<Builder, Annotation> implements io.helidon.common.Builder<Builder, Annotation> {
class Builder extends Annotation.BuilderBase<Annotation.Builder, Annotation> implements io.helidon.common.Builder<Annotation.Builder, Annotation> {

private Builder() {
}
Expand Down
49 changes: 25 additions & 24 deletions common/types/src/main/java/io/helidon/common/types/TypeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@
public interface TypeInfo extends TypeInfoBlueprint, Prototype.Api {

/**
* Create a new fluent API builder from an existing instance.
* Create a new fluent API builder to customize configuration.
*
* @param instance an existing instance used as a base for the builder
* @return a builder based on an instance
* @return a new builder
*/
static Builder builder(TypeInfo instance) {
return TypeInfo.builder().from(instance);
static TypeInfo.Builder builder() {
return new TypeInfo.Builder();
}

/**
* Create a new fluent API builder to customize configuration.
* Create a new fluent API builder from an existing instance.
*
* @return a new builder
* @param instance an existing instance used as a base for the builder
* @return a builder based on an instance
*/
static Builder builder() {
return new Builder();
static TypeInfo.Builder builder(TypeInfo instance) {
return TypeInfo.builder().from(instance);
}

/**
Expand All @@ -63,11 +63,11 @@ static Builder builder() {
* @param <BUILDER> type of the builder extending this abstract builder
* @param <PROTOTYPE> type of the prototype interface that would be built by {@link #buildPrototype()}
*/
abstract class BuilderBase<BUILDER extends BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TypeInfo> implements Prototype.Builder<BUILDER, PROTOTYPE> {
abstract class BuilderBase<BUILDER extends TypeInfo.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends TypeInfo> implements Prototype.Builder<BUILDER, PROTOTYPE> {

private final List<Annotation> annotations = new ArrayList<>();
private final List<TypedElementInfo> elementInfo = new ArrayList<>();
private final List<TypeInfo> interfaceTypeInfo = new ArrayList<>();
private final List<TypedElementInfo> elementInfo = new ArrayList<>();
private final List<TypedElementInfo> otherElementInfo = new ArrayList<>();
private final Map<TypeName, String> referencedModuleNames = new LinkedHashMap<>();
private final Map<TypeName, List<Annotation>> referencedTypeNamesToAnnotations = new LinkedHashMap<>();
Expand Down Expand Up @@ -108,7 +108,7 @@ public BUILDER from(TypeInfo prototype) {
* @param builder existing builder prototype to update this builder from
* @return updated builder instance
*/
public BUILDER from(BuilderBase<?, ?> builder) {
public BUILDER from(TypeInfo.BuilderBase<?, ?> builder) {
builder.typeName().ifPresent(this::typeName);
builder.typeKind().ifPresent(this::typeKind);
addElementInfo(builder.elementInfo());
Expand Down Expand Up @@ -170,9 +170,9 @@ public BUILDER typeName(Supplier<? extends TypeName> supplier) {
* <p>
* Such as
* <ul>
* <li>{@value TypeValues#KIND_INTERFACE}</li>
* <li>{@value TypeValues#KIND_ANNOTATION_TYPE}</li>
* <li>and other constants on {@link TypeValues}</li>
* <li>{@value io.helidon.common.types.TypeValues#KIND_INTERFACE}</li>
* <li>{@value io.helidon.common.types.TypeValues#KIND_ANNOTATION_TYPE}</li>
* <li>and other constants on {@link io.helidon.common.types.TypeValues}</li>
* </ul>
*
* @param typeKind the type element kind.
Expand Down Expand Up @@ -454,7 +454,7 @@ public BUILDER superTypeInfo(TypeInfo superTypeInfo) {
* @return updated builder instance
* @see #superTypeInfo()
*/
public BUILDER superTypeInfo(Consumer<Builder> consumer) {
public BUILDER superTypeInfo(Consumer<TypeInfo.Builder> consumer) {
Objects.requireNonNull(consumer);
var builder = TypeInfo.builder();
consumer.accept(builder);
Expand Down Expand Up @@ -509,7 +509,7 @@ public BUILDER addInterfaceTypeInfo(TypeInfo interfaceTypeInfo) {
* @return updated builder instance
* @see #interfaceTypeInfo()
*/
public BUILDER addInterfaceTypeInfo(Consumer<Builder> consumer) {
public BUILDER addInterfaceTypeInfo(Consumer<TypeInfo.Builder> consumer) {
Objects.requireNonNull(consumer);
var builder = TypeInfo.builder();
consumer.accept(builder);
Expand Down Expand Up @@ -630,9 +630,9 @@ public Optional<TypeName> typeName() {
* <p>
* Such as
* <ul>
* <li>{@value TypeValues#KIND_INTERFACE}</li>
* <li>{@value TypeValues#KIND_ANNOTATION_TYPE}</li>
* <li>and other constants on {@link TypeValues}</li>
* <li>{@value io.helidon.common.types.TypeValues#KIND_INTERFACE}</li>
* <li>{@value io.helidon.common.types.TypeValues#KIND_ANNOTATION_TYPE}</li>
* <li>and other constants on {@link io.helidon.common.types.TypeValues}</li>
* </ul>
*
* @return the type kind
Expand Down Expand Up @@ -661,7 +661,7 @@ public List<TypedElementInfo> otherElementInfo() {
}

/**
* Any Map, List, Set, or method that has {@link TypeName#typeArguments()} will be analyzed and any
* Any Map, List, Set, or method that has {@link io.helidon.common.types.TypeName#typeArguments()} will be analyzed and any
* type arguments will have
* its annotations added here. Note that this only applies to non-built-in types.
*
Expand Down Expand Up @@ -768,8 +768,8 @@ BUILDER superTypeInfo(Optional<? extends TypeInfo> superTypeInfo) {
protected static class TypeInfoImpl implements TypeInfo {

private final List<Annotation> annotations;
private final List<TypedElementInfo> elementInfo;
private final List<TypeInfo> interfaceTypeInfo;
private final List<TypedElementInfo> elementInfo;
private final List<TypedElementInfo> otherElementInfo;
private final Map<TypeName, String> referencedModuleNames;
private final Map<TypeName, List<Annotation>> referencedTypeNamesToAnnotations;
Expand All @@ -783,7 +783,7 @@ protected static class TypeInfoImpl implements TypeInfo {
*
* @param builder extending builder base of this prototype
*/
protected TypeInfoImpl(BuilderBase<?, ?> builder) {
protected TypeInfoImpl(TypeInfo.BuilderBase<?, ?> builder) {
this.typeName = builder.typeName().get();
this.typeKind = builder.typeKind().get();
this.elementInfo = List.copyOf(builder.elementInfo());
Expand Down Expand Up @@ -887,7 +887,8 @@ public int hashCode() {
/**
* Fluent API builder for {@link TypeInfo}.
*/
class Builder extends BuilderBase<Builder, TypeInfo> implements io.helidon.common.Builder<Builder, TypeInfo> {
class Builder extends TypeInfo.BuilderBase<TypeInfo.Builder, TypeInfo>
implements io.helidon.common.Builder<TypeInfo.Builder, TypeInfo> {

private Builder() {
}
Expand Down
Loading

0 comments on commit 76afdca

Please sign in to comment.