* @throws NullPointerException if type is null
*/
public static Type javaTypeForYangType(final String type) {
- switch (type) {
- case "binary":
- return BINARY_TYPE;
- case "boolean":
- return BOOLEAN_TYPE;
- case "decimal64":
- return DECIMAL64_TYPE;
- case "empty":
- return EMPTY_TYPE;
- case "enumeration":
- return ENUM_TYPE;
- case "instance-identifier":
- return INSTANCE_IDENTIFIER;
- case "int8":
- return INT8_TYPE;
- case "int16":
- return INT16_TYPE;
- case "int32":
- return INT32_TYPE;
- case "int64":
- return INT64_TYPE;
- case "string":
- return STRING_TYPE;
- case "uint8":
- return UINT8_TYPE;
- case "uint16":
- return UINT16_TYPE;
- case "uint32":
- return UINT32_TYPE;
- case "uint64":
- return UINT64_TYPE;
- default:
- return null;
- }
+ return switch (type) {
+ case "binary" -> BINARY_TYPE;
+ case "boolean" -> BOOLEAN_TYPE;
+ case "decimal64" -> DECIMAL64_TYPE;
+ case "empty" -> EMPTY_TYPE;
+ case "enumeration" -> ENUM_TYPE;
+ case "instance-identifier" -> INSTANCE_IDENTIFIER;
+ case "int8" -> INT8_TYPE;
+ case "int16" -> INT16_TYPE;
+ case "int32" -> INT32_TYPE;
+ case "int64" -> INT64_TYPE;
+ case "string" -> STRING_TYPE;
+ case "uint8" -> UINT8_TYPE;
+ case "uint16" -> UINT16_TYPE;
+ case "uint32" -> UINT32_TYPE;
+ case "uint64" -> UINT64_TYPE;
+ default -> null;
+ };
}
}
AbstractGeneratedType(final AbstractGeneratedTypeBuilder<?> builder) {
super(builder.getIdentifier());
- this.comment = builder.getComment();
- this.annotations = toUnmodifiableAnnotations(builder.getAnnotations());
- this.implementsTypes = makeUnmodifiable(builder.getImplementsTypes());
- this.constants = makeUnmodifiable(builder.getConstants());
- this.enumerations = List.copyOf(builder.getEnumerations());
- this.methodSignatures = toUnmodifiableMethods(builder.getMethodDefinitions());
- this.enclosedTypes = List.copyOf(builder.getEnclosedTransferObjects());
- this.properties = toUnmodifiableProperties(builder.getProperties());
- this.isAbstract = builder.isAbstract();
- this.definition = builder.getYangSourceDefinition().orElse(null);
+ comment = builder.getComment();
+ annotations = toUnmodifiableAnnotations(builder.getAnnotations());
+ implementsTypes = makeUnmodifiable(builder.getImplementsTypes());
+ constants = makeUnmodifiable(builder.getConstants());
+ enumerations = List.copyOf(builder.getEnumerations());
+ methodSignatures = toUnmodifiableMethods(builder.getMethodDefinitions());
+ enclosedTypes = List.copyOf(builder.getEnclosedTransferObjects());
+ properties = toUnmodifiableProperties(builder.getProperties());
+ isAbstract = builder.isAbstract();
+ definition = builder.getYangSourceDefinition().orElse(null);
}
AbstractGeneratedType(final JavaTypeName identifier, final TypeComment comment,
final List<GeneratedPropertyBuilder> propertyBuilders) {
super(identifier);
this.comment = comment;
- this.annotations = toUnmodifiableAnnotations(annotationBuilders);
+ annotations = toUnmodifiableAnnotations(annotationBuilders);
this.implementsTypes = makeUnmodifiable(implementsTypes);
this.constants = makeUnmodifiable(constants);
- this.enumerations = toUnmodifiableEnumerations(enumBuilders);
- this.methodSignatures = toUnmodifiableMethods(methodBuilders);
- this.enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);
- this.properties = toUnmodifiableProperties(propertyBuilders);
+ enumerations = toUnmodifiableEnumerations(enumBuilders);
+ methodSignatures = toUnmodifiableMethods(methodBuilders);
+ enclosedTypes = toUnmodifiableEnclosedTypes(enclosedGenTypeBuilders, enclosedGenTOBuilders);
+ properties = toUnmodifiableProperties(propertyBuilders);
this.isAbstract = isAbstract;
- this.definition = null;
+ definition = null;
}
protected static final <T> List<T> makeUnmodifiable(final List<T> list) {
- switch (list.size()) {
- case 0:
- return Collections.emptyList();
- case 1:
- return Collections.singletonList(list.get(0));
- default:
- return Collections.unmodifiableList(list);
- }
+ return switch (list.size()) {
+ case 0 -> Collections.emptyList();
+ case 1 -> Collections.singletonList(list.get(0));
+ default -> Collections.unmodifiableList(list);
+ };
}
protected static <T> Set<T> makeUnmodifiable(final Set<T> set) {
- switch (set.size()) {
- case 0:
- return Collections.emptySet();
- case 1:
- return Collections.singleton(set.iterator().next());
- default:
- return Collections.unmodifiableSet(set);
- }
+ return switch (set.size()) {
+ case 0 -> Collections.emptySet();
+ case 1 -> Collections.singleton(set.iterator().next());
+ default -> Collections.unmodifiableSet(set);
+ };
}
private static List<GeneratedType> toUnmodifiableEnclosedTypes(
@Override
public final TypeComment getComment() {
- return this.comment;
+ return comment;
}
@Override
public final List<AnnotationType> getAnnotations() {
- return this.annotations;
+ return annotations;
}
@Override
public final boolean isAbstract() {
- return this.isAbstract;
+ return isAbstract;
}
@Override
public final List<Type> getImplements() {
- return this.implementsTypes;
+ return implementsTypes;
}
@Override
public final List<GeneratedType> getEnclosedTypes() {
- return this.enclosedTypes;
+ return enclosedTypes;
}
@Override
public final List<Enumeration> getEnumerations() {
- return this.enumerations;
+ return enumerations;
}
@Override
public final List<Constant> getConstantDefinitions() {
- return this.constants;
+ return constants;
}
@Override
public final List<MethodSignature> getMethodDefinitions() {
- return this.methodSignatures;
+ return methodSignatures;
}
@Override
public final List<GeneratedProperty> getProperties() {
- return this.properties;
+ return properties;
}
@Override