All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.nifi.components.AllowableValue Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.nifi.components;

import java.util.Objects;

/**
 * 

* Represents a valid value for a {@link PropertyDescriptor} *

*/ public class AllowableValue implements DescribedValue { private final String value; private final String displayName; private final String description; /** * Constructs a new AllowableValue with the given value and and the same * display name and no description. * * @param value that is allowed */ public AllowableValue(final String value) { this(value, value); } /** * Constructs a new AllowableValue with the given value and display name and * no description * * @param value that is allowed * @param displayName to display for the value * * @throws NullPointerException if either argument is null */ public AllowableValue(final String value, final String displayName) { this(value, displayName, null); } /** * Constructs a new AllowableValue with the given value, display name, and * description * * @param value that is valid * @param displayName to show for the value * @param description of the value * * @throws NullPointerException if identifier or value is null */ public AllowableValue(final String value, final String displayName, final String description) { this.value = Objects.requireNonNull(value); this.displayName = Objects.requireNonNull(displayName); this.description = description; } /** * @return the value of this AllowableValue */ @Override public String getValue() { return value; } /** * @return a human-readable name for this AllowableValue */ @Override public String getDisplayName() { return displayName; } /** * @return a description for this value, or null if no * description was provided */ @Override public String getDescription() { return description; } /** * @return true if this is equal to obj of obj is the * same object as this or if obj is an instance of * AllowableValue and both have the same value, or if * obj is a String and is equal to * {@link #getValue() this.getValue()}. */ @Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (obj instanceof AllowableValue) { final AllowableValue other = (AllowableValue) obj; return (this.value.equals(other.getValue())); } else if (obj instanceof String) { return this.value.equals(obj); } return false; } /** * @return based solely off of the value */ @Override public int hashCode() { return 23984731 + 17 * value.hashCode(); } @Override public String toString() { return value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy