Options Class — spring-boot Architecture
Architecture documentation for the Options class in ConfigData.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigData.java lines 175–263
public static final class Options {
/**
* No options.
*/
public static final Options NONE = new Options(Collections.emptySet());
private final Set<Option> options;
private Options(Set<Option> options) {
this.options = Collections.unmodifiableSet(options);
}
Set<Option> asSet() {
return this.options;
}
/**
* Returns if the given option is contained in this set.
* @param option the option to check
* @return {@code true} of the option is present
*/
public boolean contains(Option option) {
return this.options.contains(option);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Options other = (Options) obj;
return this.options.equals(other.options);
}
@Override
public int hashCode() {
return this.options.hashCode();
}
@Override
public String toString() {
return this.options.toString();
}
/**
* Create a new {@link Options} instance that contains the options in this set
* excluding the given option.
* @param option the option to exclude
* @return a new {@link Options} instance
*/
public Options without(Option option) {
return copy((options) -> options.remove(option));
}
/**
* Create a new {@link Options} instance that contains the options in this set
* including the given option.
* @param option the option to include
* @return a new {@link Options} instance
*/
public Options with(Option option) {
return copy((options) -> options.add(option));
}
private Options copy(Consumer<EnumSet<Option>> processor) {
EnumSet<Option> options = (!this.options.isEmpty()) ? EnumSet.copyOf(this.options)
: EnumSet.noneOf(Option.class);
processor.accept(options);
return new Options(options);
}
/**
* Create a new instance with the given {@link Option} values.
* @param options the options to include
* @return a new {@link Options} instance
*/
public static Options of(Option... options) {
Assert.notNull(options, "'options' must not be null");
if (options.length == 0) {
return NONE;
}
return new Options(EnumSet.copyOf(Arrays.asList(options)));
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free