Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2010-2012 eBusiness Information, Excilys Group 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.googlecode.androidannotations.rclass;
 
 import java.util.List;
 import java.util.Map;
 
 
 
 public class RInnerClass implements IRInnerClass {
 
 	private final Map<IntegerStringidQualifiedNamesByIdValues = new HashMap<IntegerString>();
 
 	private final String rInnerQualifiedName;
 
 	public RInnerClass(TypeElement rInnerTypeElement) {
 		if (rInnerTypeElement != null) {
 
 			 = rInnerTypeElement.getQualifiedName().toString();
 
 			List<? extends ElementidEnclosedElements = rInnerTypeElement.getEnclosedElements();
 
 			List<VariableElementidFields = ElementFilter.fieldsIn(idEnclosedElements);
 
 			for (VariableElement idField : idFields) {
 				TypeKind fieldType = idField.asType().getKind();
 				if (fieldType.isPrimitive() && fieldType.equals(.)) {
 					Integer idFieldId = (IntegeridField.getConstantValue();
 					.put(idFieldId + "." + idField.getSimpleName());
 				}
 			}
 		} else {
 		}
 	}
 
 	public boolean containsIdValue(Integer idValue) {
 	}
 
 	public String getIdQualifiedName(Integer idValue) {
 		return .get(idValue);
 	}
 
 	public boolean containsField(String name) {
 		boolean containsField = .containsValue( + "." + name);
 
 		if (!containsField) {
 			String snakeCaseName = CaseHelper.camelCaseToSnakeCase(name);
 			containsField = .containsValue( + "." + snakeCaseName);
 		}
 
 		return containsField;
 	}
 
 	public String getIdQualifiedName(String name) {
 		String idQualifiedName =  + "." + name;
 
 		if (.containsValue(idQualifiedName)) {
 			return idQualifiedName;
 		} else {
 			String snakeCaseName = CaseHelper.camelCaseToSnakeCase(name);
 			idQualifiedName =  + "." + snakeCaseName;
 			if (.containsValue(idQualifiedName)) {
 				return idQualifiedName;
 			} else {
 				return null;
 			}
 		}
 	}
 
	public JFieldRef getIdStaticRef(Integer idValueEBeanHolder holder) {
		String layoutFieldQualifiedName = getIdQualifiedName(idValue);
		return extractIdStaticRef(holderlayoutFieldQualifiedName);
	}
	public JFieldRef getIdStaticRef(String nameEBeanHolder holder) {
		String layoutFieldQualifiedName = getIdQualifiedName(name);
		return extractIdStaticRef(holderlayoutFieldQualifiedName);
	}
	private JFieldRef extractIdStaticRef(EBeanHolder holderString layoutFieldQualifiedName) {
		if (layoutFieldQualifiedName != null) {
			int fieldSuffix = layoutFieldQualifiedName.lastIndexOf('.');
			String fieldName = layoutFieldQualifiedName.substring(fieldSuffix + 1);
			String rInnerClassName = layoutFieldQualifiedName.substring(0, fieldSuffix);
			JClass refClass = holder.refClass(rInnerClassName);
			return refClass.staticRef(fieldName);
else {
			return null;
		}
	}
New to GrepCode? Check out our FAQ X