/** * {@inheritDoc} * <p> * Since this is a constant, the model will first be copied and the * operation will then be performed on the copy. */ @Override public AnnotationUsage put(String key, Value<?> val) { return copy().put(requireNonNull(key), val); }
/** * {@inheritDoc} * <p> * Since this is a constant, the model will first be copied and the * operation will then be performed on the copy. */ @Override public AnnotationUsage set(Type type) { return copy().set(requireNonNull(type)); }
/** * Creates an {@link AnnotationUsage} with the specified {@code Type} and * adds it to this model. * * @param annotation the new annotation usage * @return a reference to this * * @since 2.5 */ default T annotate(final Type annotation) { return annotate(AnnotationUsage.of(annotation)); }
addType(a.getType(), types) );
/** * Copy constructor. * * @param prototype the prototype */ protected EnumConstantImpl(EnumConstant prototype) { name = requireNonNull(prototype).getName(); javadoc = prototype.getJavadoc().orElse(null); imports = Copier.copy(prototype.getImports()); classes = Copier.copy(prototype.getClasses(), c -> c.copy()); initializers = Copier.copy(prototype.getInitializers(), c -> c.copy()); methods = Copier.copy(prototype.getMethods(), c -> c.copy()); fields = Copier.copy(prototype.getFields(), c -> c.copy()); values = Copier.copy(prototype.getValues(), c -> c.copy()); annotations = Copier.copy(prototype.getAnnotations(), c -> c.copy()); }
/** * {@inheritDoc} * <p> * Since this is a constant, the model will first be copied and the * operation will then be performed on the copy. */ @Override public AnnotationUsage set(Value<?> val) { return copy().set(val); }
@Override public AnnotationUsage copy() { final AnnotationUsage copy = AnnotationUsage.of(getType()); getValue().ifPresent(copy::set); return copy; } }
/** * Copy constructor. * * @param prototype the prototype */ protected EnumConstantImpl(EnumConstant prototype) { name = requireNonNull(prototype).getName(); javadoc = prototype.getJavadoc().orElse(null); imports = Copier.copy(prototype.getImports()); classes = Copier.copy(prototype.getClasses(), c -> c.copy()); initializers = Copier.copy(prototype.getInitializers(), c -> c.copy()); methods = Copier.copy(prototype.getMethods(), c -> c.copy()); fields = Copier.copy(prototype.getFields(), c -> c.copy()); values = Copier.copy(prototype.getValues(), c -> c.copy()); annotations = Copier.copy(prototype.getAnnotations(), c -> c.copy()); }
/** * Creates an {@link AnnotationUsage} with the specified {@code Type} and * adds it to this model. This method will also set the {@code value()} * of the annotation to {@code textValue}. * * @param annotation the new annotation usage * @param textValue the value of the text for this annotation * @return a reference to this * * @since 2.5 */ default T annotate(final Type annotation, String textValue) { return annotate(AnnotationUsage.of(annotation).set(ofText(textValue))); }
@Override public Optional<String> transform(Generator gen, AnnotationUsage model) { requireNonNull(gen); requireNonNull(model); final Optional<String> value = gen.on(model.getValue()); final Stream<String> valueStream = value.map(Stream::of).orElseGet(Stream::empty); return Optional.of( "@" + gen.on(model.getType()).orElseThrow(NoSuchElementException::new) + Stream.of( model.getValues().stream() .map(e -> e.getKey() + gen.on(e.getValue()) .map(s -> " = " + s) .orElse("") ), valueStream ).flatMap(s -> s).collect( joinIfNotEmpty(", ", "(", ")") ) ); } }
/** * {@inheritDoc} * <p> * Since this is a constant, the model will first be copied and the * operation will then be performed on the copy. */ @Override public AnnotationUsage set(Type type) { return copy().set(requireNonNull(type)); }
/** * Creates an {@link AnnotationUsage} with the specified {@code Type} and * adds it to this model. * * @param annotation the new annotation usage * @return a reference to this * * @since 2.5 */ default T annotate(final Type annotation) { return annotate(AnnotationUsage.of(annotation)); }
/** * Use the specified key-value pair when referencing the annotation. If you * only want to show a single value without any key, consider using the * {@link #set(Value)} method. * <p> * This method works like {@link #put(String, Value)} except that the type * of the value is automatically determined as a {@link NumberValue}. * * @param key the key * @param numberValue the value * @return a reference to this model * * @since 2.5 */ default AnnotationUsage put(String key, Number numberValue) { return put(key, Value.ofNumber(numberValue)); }
/** * {@inheritDoc} * <p> * Since this is a constant, the model will first be copied and the * operation will then be performed on the copy. */ @Override public AnnotationUsage set(Value<?> val) { return copy().set(val); }
@Override public AnnotationUsage copy() { final AnnotationUsage copy = AnnotationUsage.of(getType()); getValue().ifPresent(copy::set); return copy; } }
/** * Use the specified key-value pair when referencing the annotation. If you * only want to show a single value without any key, consider using the * {@link #set(Value)} method. * <p> * This method works like {@link #put(String, Value)} except that the type * of the value is automatically determined as a {@link TextValue}. * * @param key the key * @param textValue the value * @return a reference to this model * * @since 2.5 */ default AnnotationUsage put(String key, String textValue) { return put(key, Value.ofText(textValue)); }