@Override public Optional<String> transform(Generator gen, Generic model) { requireNonNulls(gen, model); if (!model.getLowerBound().isPresent() && model.getUpperBounds().isEmpty()) { return Optional.empty(); } else { return Optional.of( model.getLowerBound().orElse("") + gen.onEach(model.getUpperBounds()).collect(joinIfNotEmpty("&", model.getLowerBound().isPresent() ? model.getBoundType() == Generic.BoundType.EXTENDS ? " extends " : " super " : "", "" ) ) ); } } }
/** * Creates a new instance implementing this interface by using the default * implementation. * * @param lowerBound the lower bound, example: {@code "T"} * @return the new instance */ static Generic of(String lowerBound) { return of().setLowerBound(lowerBound); }
/** * Copy constructor. * * @param prototype the prototype */ protected GenericImpl(Generic prototype) { lowerBound = prototype.getLowerBound().orElse(null); upperBounds = new ArrayList<>(prototype.getUpperBounds()); }
/** * Adds an upper bound to this generic. * <p> * In the following example, <code>List<String></code> and * <code>Serializable</code> are upper bounds: * <pre> * T extends List<String>&Serializable * </pre> * * @param upperBound the new upper bound * @return a reference to this model */ default Generic add(Type upperBound) { getUpperBounds().add(upperBound); return this; }
/** * Created a new {@link Generic} with the specified name and adds it to this * model. * * @param generic the name of the new generic variable * @return a reference to this * * @since 2.5 */ default T generic(final String generic) { return add(Generic.of(generic)); }
g.getLowerBound().ifPresent(t -> addTag(doc, PARAM.setValue("<" + t + ">") ))
/** * Copy constructor. * * @param prototype the prototype */ protected GenericImpl(Generic prototype) { lowerBound = prototype.getLowerBound().orElse(null); upperBounds = new ArrayList<>(prototype.getUpperBounds()); }
g.getUpperBounds().forEach(ub -> addType(ub, types)
/** * Created a new {@link Generic} with the specified type and adds it to this * model. * * @param generic the type of the new generic variable * @return a reference to this * * @since 2.5 */ default T generic(final Type generic) { return add(Generic.of(generic)); }
g.getLowerBound().ifPresent(t -> addTag(doc, PARAM.setValue("<" + t + ">") ))
@Override public Optional<String> transform(Generator gen, Generic model) { requireNonNulls(gen, model); if (!model.getLowerBound().isPresent() && model.getUpperBounds().isEmpty()) { return Optional.empty(); } else { return Optional.of( model.getLowerBound().orElse("") + gen.onEach(model.getUpperBounds()).collect(joinIfNotEmpty("&", model.getLowerBound().isPresent() ? model.getBoundType() == Generic.BoundType.EXTENDS ? " extends " : " super " : "", "" ) ) ); } } }
/** * Created a new {@link Generic} with the specified name and type and adds * it to this model. The {@link Generic#getBoundType() bound type} of the * new {@link Generic} will be {@link Generic.BoundType#EXTENDS}. * * @param name the name of the new generic * @param type the upper bound of the new generic * @return a reference to this * * @since 2.5 */ default T generic(final String name, final Type type) { return add(Generic.of(name).add(type)); }
/** * Creates a new instance implementing this interface by using the default * implementation. * * @param lowerBound the lower bound, example: {@code "T"} * @return the new instance */ static Generic of(String lowerBound) { return of().setLowerBound(lowerBound); }
/** * Copy constructor. * * @param prototype the prototype */ protected GenericImpl(Generic prototype) { lowerBound = prototype.getLowerBound().orElse(null); upperBounds = new ArrayList<>(prototype.getUpperBounds()); }
/** * Adds an upper bound to this generic. * <p> * In the following example, <code>List<String></code> and * <code>Serializable</code> are upper bounds: * <pre> * T extends List<String>&Serializable * </pre> * * @param upperBound the new upper bound * @return a reference to this model */ default Generic add(Type upperBound) { getUpperBounds().add(upperBound); return this; }
/** * Created a new {@link Generic} with the specified name and adds it to this * model. * * @param generic the name of the new generic variable * @return a reference to this * * @since 2.5 */ default T generic(final String generic) { return add(Generic.of(generic)); }
g.getLowerBound().ifPresent(t -> addTag(doc, PARAM.setValue("<" + t + ">") ))
@Override public Optional<String> transform(Generator gen, Generic model) { requireNonNulls(gen, model); if (!model.getLowerBound().isPresent() && model.getUpperBounds().isEmpty()) { return Optional.empty(); } else { return Optional.of( model.getLowerBound().orElse("") + gen.onEach(model.getUpperBounds()).collect(joinIfNotEmpty("&", model.getLowerBound().isPresent() ? model.getBoundType() == Generic.BoundType.EXTENDS ? " extends " : " super " : "", "" ) ) ); } } }