br.com.objectos.code.AutoMethodInfo Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2016 Objectos, Fábrica de Software LTDA.
*
* 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 br.com.objectos.code;
import static br.com.objectos.code.AutoParameterInfo.single;
import static br.com.objectos.code.AutoSimpleTypeInfo.javaLang;
import static br.com.objectos.code.SimpleTypePrimitives.BOOLEAN;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import br.com.objectos.core.util.ImmutableList;
import br.com.objectos.core.util.ImmutableSet;
/**
* @author [email protected] (Marcio Endo)
*/
public final class AutoMethodInfo extends MethodInfo {
private static final List OBJECT_METHOD_LIST = ImmutableList. builder()
.add(of("toString", javaLang("String")))
.add(of("equals", BOOLEAN, single(javaLang("Object"), "o")))
.add(of("hashCode", SimpleTypePrimitives.INT))
.build();
private final String name;
private final SimpleTypeInfo returnTypeInfo;
private final List parameterInfoList;
private AutoMethodInfo(String name, SimpleTypeInfo returnTypeInfo, List parameterInfoList) {
this.name = name;
this.returnTypeInfo = returnTypeInfo;
this.parameterInfoList = parameterInfoList;
}
public static Stream objectMethodStream() {
return OBJECT_METHOD_LIST.stream();
}
private static MethodInfo of(String name, SimpleTypeInfo returnTypeInfo, ParameterInfo... parameters) {
List parameterInfoList = Arrays.asList(parameters);
return new AutoMethodInfo(name, returnTypeInfo, parameterInfoList);
}
@Override
public AccessInfo accessInfo() {
return AccessInfo.PUBLIC;
}
@Override
Set modifierInfoSet() {
return ImmutableSet.of();
}
@Override
public String name() {
return name;
}
@Override
public List annotationInfoList() {
return ImmutableList.of();
}
@Override
public SimpleTypeInfo returnTypeInfo() {
return returnTypeInfo;
}
@Override
List parameterInfoList() {
return parameterInfoList;
}
@Override
public boolean varargs() {
return false;
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy