blob: e7910dc7bd3ce415e6b5c244f89b5ee9121f47a1 [file] [log] [blame]
/*
* Copyright 2016 The Bazel Authors. All rights reserved.
*
* 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.google.idea.blaze.base.projectview.section;
import com.google.common.base.Objects;
import java.io.Serializable;
/** Key to a section of type T. */
public final class SectionKey<T, SectionType extends Section<T>> implements Serializable {
private static final long serialVersionUID = 1L;
private final String name;
public SectionKey(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static <T, SectionType extends Section<T>> SectionKey<T, SectionType> of(String name) {
return new SectionKey<>(name);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SectionKey<?, ?> that = (SectionKey<?, ?>) o;
return Objects.equal(name, that.name);
}
@Override
public int hashCode() {
return Objects.hashCode(name);
}
}