/* * Copyright (C) 2007 The Android Open Source Project * * 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 com.android.ide.common.resources.configuration; /** * Base class for resource qualifiers. *
The resource qualifier classes are designed as immutable. */ public abstract class ResourceQualifier implements Comparabletrue
.
* @param reference The reference qualifier value for which the match is.
* @return true if the receiver is a better match.
*/
public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) {
// the default is to always return false. This gives less overhead than always returning
// true, as it would only compare same values anyway.
return false;
}
@Override
public String toString() {
return getFolderSegment();
}
/**
* Returns a string formatted for display purpose.
*/
public abstract String getShortDisplayValue();
/**
* Returns a string formatted for display purpose.
*/
public abstract String getLongDisplayValue();
/**
* Returns true
if both objects are equal.
* This is declared as abstract to force children classes to implement it.
*/
@Override
public abstract boolean equals(Object object);
/**
* Returns a hash code value for the object.
* This is declared as abstract to force children classes to implement it.
*/
@Override
public abstract int hashCode();
@Override
public final int compareTo(ResourceQualifier o) {
return toString().compareTo(o.toString());
}
}