/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.litho.specmodels.model;
import javax.annotation.concurrent.Immutable;
import java.lang.annotation.Annotation;
import java.util.List;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.TypeName;
/**
* Model that is a simple base representation of a method param.
*/
@Immutable
public class SimpleMethodParamModel implements MethodParamModel {
private final TypeName mType;
private final String mName;
private final List<Annotation> mAnnotations;
private final List<AnnotationSpec> mExternalAnnotations;
private final Object mRepresentedObject;
SimpleMethodParamModel(
TypeName type,
String name,
List<Annotation> annotations,
List<AnnotationSpec> externalAnnotations,
Object representedObject) {
mType = type;
mName = name;
mAnnotations = annotations;
mExternalAnnotations = externalAnnotations;
mRepresentedObject = representedObject;
}
@Override
public TypeName getType() {
return mType;
}
@Override
public String getName() {
return mName;
}
@Override
public List<Annotation> getAnnotations() {
return mAnnotations;
}
@Override
public List<AnnotationSpec> getExternalAnnotations() {
return mExternalAnnotations;
}
@Override
public Object getRepresentedObject() {
return mRepresentedObject;
}
@Override
public boolean equals(Object o) {
if (o instanceof SimpleMethodParamModel) {
final SimpleMethodParamModel p = (SimpleMethodParamModel) o;
return mType.equals(p.mType) && mName.equals(p.mName) && mAnnotations.equals(p.mAnnotations);
}
return false;
}
@Override
public int hashCode() {
int result = mType.hashCode();
result = 17 * result + mName.hashCode();
result = 31 * result + mAnnotations.hashCode();
return result;
}
}