br.com.objectos.code.EnumConstantInfoVariableElement Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2015 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 javax.lang.model.element.Name;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import br.com.objectos.lazy.Lazy;
/**
* @author [email protected] (Marcio Endo)
*/
class EnumConstantInfoVariableElement extends EnumConstantInfo {
private final ProcessingEnvironmentWrapper processingEnv;
private final VariableElement element;
private final Lazy enumType = new LazySimpleTypeInfo();
private EnumConstantInfoVariableElement(ProcessingEnvironmentWrapper processingEnv, VariableElement element) {
this.processingEnv = processingEnv;
this.element = element;
}
public static EnumConstantInfo wrap(ProcessingEnvironmentWrapper processingEnv, VariableElement element) {
return new EnumConstantInfoVariableElement(processingEnv, element);
}
@Override
public SimpleTypeInfo enumType() {
return enumType.get();
}
@Override
public String value() {
Name simpleName = element.getSimpleName();
return simpleName.toString();
}
private class LazySimpleTypeInfo extends Lazy {
@Override
protected SimpleTypeInfo compute() {
TypeMirror type = element.asType();
TypeParameterInfo parameterInfo = TypeParameterInfoTypeMirror.wrap(processingEnv, type);
return parameterInfo.simpleTypeInfo();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy