ru.blizzed.openlastfm.methods.ApiParamDescription Maven / Gradle / Ivy
Show all versions of openlastfm Show documentation
/*
* Copyright (c) 2017 BlizzedRu (Ivan Vlasov)
*
* Licensed 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 ru.blizzed.openlastfm.methods;
import ru.blizzed.openlastfm.params.Param;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Class represents a description for single {@link Param}
*
It is used for describe a {@link Param}:
* is it required and if yes – which {@link Param} (or params) can replace it
*
* E.g. there are two required params artist and album in method album.getInfo,
* but it can be replaced by param mbid
*
In this case each of two required params has replacement – param mbid
*
* @author BlizzedRu
*/
public final class ApiParamDescription {
private Param param;
private boolean isRequired;
private List replacements;
public ApiParamDescription(Param param, boolean isRequired) {
this.param = param;
this.isRequired = isRequired;
}
public ApiParamDescription(Param param, boolean isRequired, Param... replacements) {
this.param = param;
this.isRequired = isRequired;
this.replacements = Arrays.asList(replacements);
}
public Param getParam() {
return param;
}
public boolean isRequired() {
return isRequired;
}
public boolean hasReplacements() {
return replacements != null;
}
/**
* Returns a {@link List} of replacements
*
* @return {@link List} of replacements or empty list if absent
*/
public List getReplacements() {
if (replacements == null) return Collections.emptyList();
return replacements;
}
}