blob: 6c67727ce94be322236b9c7754a61a6e108853cc [file] [log] [blame]
/*
* 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.flink.configuration;
/**
* A key with FallbackKeys will fall back to the FallbackKeys if it itself is not configured.
*/
public class FallbackKey {
// -------------------------
// Factory methods
// -------------------------
static FallbackKey createFallbackKey(String key) {
return new FallbackKey(key, false);
}
static FallbackKey createDeprecatedKey(String key) {
return new FallbackKey(key, true);
}
// ------------------------------------------------------------------------
private final String key;
private final boolean isDeprecated;
public String getKey() {
return key;
}
public boolean isDeprecated() {
return isDeprecated;
}
private FallbackKey(String key, boolean isDeprecated) {
this.key = key;
this.isDeprecated = isDeprecated;
}
// ------------------------------------------------------------------------
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o != null && o.getClass() == FallbackKey.class) {
FallbackKey that = (FallbackKey) o;
return this.key.equals(that.key) && (this.isDeprecated == that.isDeprecated);
} else {
return false;
}
}
@Override
public int hashCode() {
return 31 * key.hashCode() + (isDeprecated ? 1 : 0);
}
@Override
public String toString() {
return String.format("{key=%s, isDeprecated=%s}", key, isDeprecated);
}
}