Home / Class/ ItemHint Class — spring-boot Architecture

ItemHint Class — spring-boot Architecture

Architecture documentation for the ItemHint class in ItemHint.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

configuration-metadata/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java lines 39–157

public class ItemHint implements Comparable<ItemHint> {

	private final String name;

	private final List<ValueHint> values;

	private final List<ValueProvider> providers;

	public ItemHint(String name, List<ValueHint> values, List<ValueProvider> providers) {
		this.name = toCanonicalName(name);
		this.values = (values != null) ? new ArrayList<>(values) : new ArrayList<>();
		this.providers = (providers != null) ? new ArrayList<>(providers) : new ArrayList<>();
	}

	private String toCanonicalName(String name) {
		int dot = name.lastIndexOf('.');
		if (dot != -1) {
			String prefix = name.substring(0, dot);
			String originalName = name.substring(dot);
			return prefix + ConventionUtils.toDashedCase(originalName);
		}
		return ConventionUtils.toDashedCase(name);
	}

	public String getName() {
		return this.name;
	}

	public List<ValueHint> getValues() {
		return Collections.unmodifiableList(this.values);
	}

	public List<ValueProvider> getProviders() {
		return Collections.unmodifiableList(this.providers);
	}

	/**
	 * Return an {@link ItemHint} with the given prefix applied.
	 * @param prefix the prefix to apply
	 * @return a new {@link ItemHint} with the same of this instance whose property name
	 * has the prefix applied to it
	 */
	public ItemHint applyPrefix(String prefix) {
		return new ItemHint(ConventionUtils.toDashedCase(prefix) + "." + this.name, this.values, this.providers);
	}

	@Override
	public int compareTo(ItemHint other) {
		return getName().compareTo(other.getName());
	}

	public static ItemHint newHint(String name, ValueHint... values) {
		return new ItemHint(name, Arrays.asList(values), Collections.emptyList());
	}

	@Override
	public String toString() {
		return "ItemHint{name='" + this.name + "', values=" + this.values + ", providers=" + this.providers + '}';
	}

	/**
	 * A hint for a value.
	 */
	public static class ValueHint {

		private final Object value;

		private final String description;

		public ValueHint(Object value, String description) {
			this.value = value;
			this.description = description;
		}

		public Object getValue() {
			return this.value;
		}

		public String getDescription() {
			return this.description;
		}

		@Override
		public String toString() {
			return "ValueHint{value=" + this.value + ", description='" + this.description + '\'' + '}';
		}

	}

	/**
	 * A value provider.
	 */
	public static class ValueProvider {

		private final String name;

		private final Map<String, Object> parameters;

		public ValueProvider(String name, Map<String, Object> parameters) {
			this.name = name;
			this.parameters = parameters;
		}

		public String getName() {
			return this.name;
		}

		public Map<String, Object> getParameters() {
			return this.parameters;
		}

		@Override
		public String toString() {
			return "ValueProvider{name='" + this.name + "', parameters=" + this.parameters + '}';
		}

	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free