
io.sundr.examples.codegen.Property Maven / Gradle / Ivy
/*
* Copyright 2016 The original authors.
*
* 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 io.sundr.examples.codegen;
import io.sundr.builder.annotations.Buildable;
import java.util.Map;
import java.util.Set;
@Buildable
public class Property extends ModifierSupport {
private final Set annotations;
private final TypeRef typeRef;
private final String name;
public Property(Set annotations, TypeRef typeRef, String name, int modifiers, Map attributes) {
super(modifiers, attributes);
this.annotations = annotations;
this.typeRef = typeRef;
this.name = name;
}
public Set getAnnotations() {
return annotations;
}
public TypeRef getTypeRef() {
return typeRef;
}
public String getName() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Property property = (Property) o;
if (typeRef != null ? !typeRef.equals(property.typeRef) : property.typeRef != null) return false;
return name != null ? name.equals(property.name) : property.name == null;
}
@Override
public int hashCode() {
int result = typeRef != null ? typeRef.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (isPublic()) {
sb.append("public ");
} else if (isProtected()) {
sb.append("protected ");
} else if (isPrivate()) {
sb.append("private ");
}
if (isSynchronized()) {
sb.append("synchronized ");
}
if (isStatic()) {
sb.append("static ");
}
if (isFinal()) {
sb.append("final ");
}
sb.append(typeRef).append(" ");
sb.append(name);
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy