Returns the struct object inspector

@param structFieldNames
the field names
@param structFieldObjectInspectors
the object inspectors
@param xmlProcessor
the XML processor
@return the struct object inspector
335383
public static StructObjectInspector getStandardStructObjectInspector(List<String> structFieldNames,
        List<ObjectInspector> structFieldObjectInspectors,
        XmlProcessor xmlProcessor) {
        return new XmlStructObjectInspector(structFieldNames, structFieldObjectInspectors, xmlProcessor);
    }
589867
public static JMapAccessor getFieldAccessors(Class<?> clazz, Field field){
		return getFieldAccessors(clazz,field,false, field.getName(),Constants.DEFAULT_FIELD_VALUE);
	}
160440
private void generateInjectAdapter(TypeElement type, ExecutableElement constructor,
      List<Element> fields) throws IOException {
    String packageName = getPackage(type).getQualifiedName().toString();
    TypeMirror supertype = getApplicationSupertype(type);
    if (supertype != null) {
      supertype = processingEnv.getTypeUtils().erasure(supertype);
    }
    ClassName injectedClassName = ClassName.get(type);
    ClassName adapterClassName = adapterName(injectedClassName, INJECT_ADAPTER_SUFFIX);

    boolean isAbstract = type.getModifiers().contains(ABSTRACT);
    boolean injectMembers = !fields.isEmpty() || supertype != null;
    boolean disambiguateFields = !fields.isEmpty()
        && (constructor != null)
        && !constructor.getParameters().isEmpty();
    boolean dependent = injectMembers
        || ((constructor != null) && !constructor.getParameters().isEmpty());

    TypeSpec.Builder result = TypeSpec.classBuilder(adapterClassName.simpleName())
        .addOriginatingElement(type)
        .addModifiers(PUBLIC, FINAL)
        .superclass(ParameterizedTypeName.get(ClassName.get(Binding.class), injectedClassName))
        .addJavadoc("$L", bindingTypeDocs(injectableType(type.asType()), isAbstract,
            injectMembers, dependent).toString());

    for (Element field : fields) {
      result.addField(memberBindingField(disambiguateFields, field));
    }
    if (constructor != null) {
      for (VariableElement parameter : constructor.getParameters()) {
        result.addField(parameterBindingField(disambiguateFields, parameter));
      }
    }
    if (supertype != null) {
      result.addField(supertypeBindingField(supertype));
    }

    result.addMethod(writeInjectAdapterConstructor(constructor, type, injectedClassName));
    if (dependent) {
      result.addMethod(attachMethod(
          constructor, fields, disambiguateFields, injectedClassName, supertype, true));
      result.addMethod(getDependenciesMethod(
          constructor, fields, disambiguateFields, supertype, true));
    }
    if (constructor != null) {
      result.addMethod(
          getMethod(constructor, disambiguateFields, injectMembers, injectedClassName));
    }
    if (injectMembers) {
      result.addMethod(
          membersInjectMethod(fields, disambiguateFields, injectedClassName, supertype));
    }

    JavaFile javaFile = JavaFile.builder(packageName, result.build())
        .addFileComment(AdapterJavadocs.GENERATED_BY_DAGGER)
        .build();
    javaFile.writeTo(processingEnv.getFiler());
  }
940888
static private int countStructFields(ObjectInspector x, ArrayList<String> allColumnNames) {
    int res = 1;
    switch(x.getCategory()) {
      case STRUCT:
        StructObjectInspector structObjectInspector = (StructObjectInspector) x;
        List<StructField> allColumns = (List<StructField>) structObjectInspector.getAllStructFieldRefs(); // column info
        for (StructField oneField : allColumns) {
          allColumnNames.add(oneField.getFieldName());
          res += countStructFields(oneField.getFieldObjectInspector(),allColumnNames);
        }
        break;
      case LIST:
        ListObjectInspector listObjectInspector = (ListObjectInspector) x;
        allColumnNames.add("list");
        res += countStructFields(listObjectInspector.getListElementObjectInspector(),allColumnNames);
        break;
      case MAP:
        MapObjectInspector mapObjectInspector = (MapObjectInspector) x;
        allColumnNames.add("mapKey");
        res += countStructFields(mapObjectInspector.getMapKeyObjectInspector(),allColumnNames);
        allColumnNames.add("mapValue");
        res += countStructFields(mapObjectInspector.getMapValueObjectInspector(),allColumnNames);
        break;
      case UNION:
        UnionObjectInspector unionObjectInspector = (UnionObjectInspector)x;
        allColumnNames.add("union");
        for( ObjectInspector xx:unionObjectInspector.getObjectInspectors())
          res += countStructFields(xx,allColumnNames);
        break;
      case PRIMITIVE:break;
      default: throw H2O.unimpl();
    }
    return res;
  }
1057156
Violation areFieldsImmutable(
      Optional<ClassTree> tree,
      ImmutableSet<String> immutableTyParams,
      ClassType classType,
      ViolationReporter reporter) {
    ClassSymbol classSym = (ClassSymbol) classType.tsym;
    if (classSym.members() == null) {
      return Violation.absent();
    }
    Filter<Symbol> instanceFieldFilter =
        new Filter<Symbol>() {
          @Override
          public boolean accepts(Symbol symbol) {
            return symbol.getKind() == ElementKind.FIELD && !symbol.isStatic();
          }
        };
    Map<Symbol, Tree> declarations = new HashMap<>();
    if (tree.isPresent()) {
      for (Tree member : tree.get().getMembers()) {
        Symbol sym = ASTHelpers.getSymbol(member);
        if (sym != null) {
          declarations.put(sym, member);
        }
      }
    }
    // javac gives us members in reverse declaration order
    // handling them in declaration order leads to marginally better diagnostics
    List<Symbol> members =
        ImmutableList.copyOf(classSym.members().getSymbols(instanceFieldFilter)).reverse();
    for (Symbol member : members) {
      Optional<Tree> memberTree = Optional.ofNullable(declarations.get(member));
      Violation info =
          isFieldImmutable(
              memberTree, immutableTyParams, classSym, classType, (VarSymbol) member, reporter);
      if (info.isPresent()) {
        return info;
      }
    }
    return Violation.absent();
  }
1301075
public static final <T> Field getField(Class<T> cls, String fieldName) {
        try {
            Field f = cls.getDeclaredField(fieldName);
            f.setAccessible(true);
            return f;
        } catch (SecurityException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException e) {
            if (cls.getSuperclass() != null) {
                return getField(cls.getSuperclass(), fieldName);
            }
            throw new RuntimeException(e);
        }
    }
791356
public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field) {
		return injectField(typeNode, field, false);
	}
28253
public ArrayList getFields(String fieldNames) throws NoSuchFieldException
    {
        ArrayList          result    = new ArrayList();
        FieldDescriptorDef fieldDef;
        String             name;

        for (CommaListIterator it = new CommaListIterator(fieldNames); it.hasNext();)
        {
            name = it.getNext();
            fieldDef = getField(name);
            if (fieldDef == null)
            {
                throw new NoSuchFieldException(name);
            }
            result.add(fieldDef);
        }
        return result;
    }
1284809
public String retrieveTargetFieldName(final Field field){
		
		// this list contains the configuredClass with super classes
		List<Class<?>> classes = getAllsuperClasses(configuredClass);
		
		// in case of override only the last global configuration must be analyzed
		Global global = null; 
		// If configuredClass exists in XML configuration file
		for (Class<?> clazz : classes){
		  
		  if(!xml.isMapped(clazz))continue;

		  // only if global configuration is null will be searched global configuration on super classes
		  if(isNull(global)){
			  
			  global = xml.loadGlobals().get(clazz.getName());
			  if( !isNull(global) 
				  && !isPresent(global.getExcluded(), field.getName())
				  && (	isEmpty(global.getAttributes()) 
					 || isPresent(global.getAttributes(), new SimplyAttribute(field.getName()))
					 )
				 ){
				  // get the classes of the xmlField
				  List<Class<?>> globalClasses = toList(global.getClasses());
				  
				  // if mapped field hasn't targetClass in classes parameter
				  if(!globalClasses.isEmpty() && !globalClasses.contains(targetClass)) continue;
				  
				  // get value of xmlField
				  String value = global.getValue();
				  
				  // If the Value is empty, 
				  // then the name of the target field is equal to the configuredField name, 
				  // therefore we pass the default value we use to indicate equality
				  if(isNull(value)) value = DEFAULT_FIELD_VALUE;
				  
				  // loaded all variables, calculates and returns the correspondence
				  return getValue(Collections.<String>emptyList(), globalClasses, value, field.getName(), clazz, targetClass);
			  }
		  }
			  
		  // loads all configured attributes 
		  for(Attribute attribute :xml.loadAttributes().get(clazz.getName())){
				
			// verifies that exists the attribute written in XML in the configured Class
			if(isNull(fieldName(clazz,attribute.getName())))	
				Error.attributeAbsent(clazz, attribute);
				
			// if the field given in input isn't equal to xmlField continue with the cycle
			if(!attribute.getName().equals(field.getName())) continue;
				
			// get the classes of the xmlField
			List<Class<?>> attributeClasses = toList(attribute.getClasses());
				
			// if mapped field hasn't targetClass in classes parameter
			if(!attributeClasses.isEmpty() && !attributeClasses.contains(targetClass)) continue;
								
			// get the attributes names of xmlField
			List<String> attributes = new ArrayList<String>();
			if(attribute.getAttributes() != null)
				for (SimplyAttribute targetAttribute : attribute.getAttributes()) 
					attributes.add(targetAttribute.getName());
				
			// get value of xmlField
			String value = null;
			if(!isNull(attribute.getValue()))
				value = attribute.getValue().getName();
			
			// If the Value and Attributes parameters are empty, 
			// then the name of the target field is equal to the configuredField name, 
			// therefore we pass the default value we use to indicate equality
			if(isNull(value) && attributes.isEmpty()) value = DEFAULT_FIELD_VALUE;
				
			// loaded all variables, calculates and returns the correspondence
			return getValue(attributes, attributeClasses, value, field.getName(), clazz, targetClass);
		  }
	    }
		
		// if class is configured in xml the annotated configuration is not searched
		// if it has a configured superclass it's ignored, the priority is valid only for principal class
		if(xml.isInheritedMapped(configuredClass))return THE_FIELD_IS_NOT_CONFIGURED;
		
		// if the XML configuration doesn't exist, checks the annotation existence
		for (Class<?> clazz : classes){
			
			JGlobalMap jglobalMap = clazz.getAnnotation(JGlobalMap.class);
			
			//if the field configuration is defined in the global map
			if(  !isNull(jglobalMap)){
				if(!isPresent(jglobalMap.excluded(), field.getName())
						&& (    isEmpty(jglobalMap.attributes()) 
								|| isPresent(jglobalMap.attributes(), field.getName())
								)){
					
					// get the list of target classes
					List<Class<?>> globalClasses = toList(jglobalMap.classes());
					
					// if mapped field hasn't targetClass in classes parameter
					if(!globalClasses.isEmpty() && !globalClasses.contains(targetClass)) return THE_FIELD_IS_NOT_CONFIGURED;
					
					// get value of configuredField
					String value = jglobalMap.value();
					
					// loaded all variables, calculates and returns the correspondence
					return getValue(Collections.<String>emptyList(), globalClasses, value, field.getName(), configuredClass, targetClass);			
				}
				// If global mapping is defined on this level, global mapping of super classes is ignored.
				// This is necessary to apply configuration override.
				break;
			}
		}
			
		JMap jmap = field.getAnnotation(JMap.class);
		if(isNull(jmap)) return THE_FIELD_IS_NOT_CONFIGURED;
			
		// get the list of target classes
		List<Class<?>> targetClasses = toList(jmap.classes());
			
		// if mapped field hasn't targetClass in classes parameter
		if(!targetClasses.isEmpty() && !targetClasses.contains(targetClass)) return THE_FIELD_IS_NOT_CONFIGURED;
			
		// get the list of target attributes
		List<String> attributes = toList(jmap.attributes());
		
		// get value of configuredField
		String value = jmap.value();
			
		// loaded all variables, calculates and returns the correspondence
		return getValue(attributes, targetClasses, value, field.getName(), configuredClass, targetClass);
		
	}
972673
private static MappedField checkAccessors(XML xml, Class<?> aClass, Field nestedField){

		MappedField field = checkGetAccessor(xml, aClass, nestedField);
		verifySetterMethods(aClass,field);
		return field;
	}
133041
private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException {
		ArrayList<JaxInfo> fields = null; // allow for lazy instantiation, because many structures won't have XmlType
		Class<?> cls = clazz;
		// Build up Method names from JAXB Annotations
		XmlType xt;
		while((xt = cls.getAnnotation(XmlType.class))!=null) {
			if(fields==null)fields = new ArrayList<JaxInfo>();
			for(String field : xt.propOrder()) {
				if("".equals(field)) break; // odd bug.  "" returned when no fields exist, rather than empty array
				Field rf = cls.getDeclaredField(field);
				Class<?> ft = rf.getType();
				
				boolean required = false;
				boolean nillable = false;
				String xmlName = field;
				String namespace = defaultNS;
				
				XmlElement xe = rf.getAnnotation(XmlElement.class);
				if(xe!=null) {
					xmlName=xe.name();
					required = xe.required();
					nillable = false;
					if(DEFAULT.equals(xmlName)) {
						xmlName = field;
					}
					namespace = xe.namespace();
					if(DEFAULT.equals(namespace)) {
						namespace = defaultNS;
					}
				}
				// If object is a List, then it is possible multiple, per XML/JAXB evaluation
				if(ft.isAssignableFrom(List.class)) {
					Type t = rf.getGenericType();
					String classname = t.toString();
					int start = classname.indexOf('<');
					int end = classname.indexOf('>');
					Class<?> genClass = Class.forName(classname.substring(start+1, end));
					xe = genClass.getAnnotation(XmlElement.class);
					if(xe!=null && !DEFAULT.equals(xe.namespace())) {
						namespace = xe.namespace();
					}
					// add recursed recursed member, marked as array
					fields.add(new JaxInfo(xmlName,namespace,genClass,buildFields(genClass,namespace), genClass.equals(String.class),true,required,nillable));
				} else {
					boolean isString = ft.equals(String.class) || ft.equals(XMLGregorianCalendar.class);
					// add recursed member
					fields.add(new JaxInfo(xmlName,namespace,ft,buildFields(ft,namespace),isString,false,required,nillable));
				}
			}
			cls = cls.getSuperclass();
		};
		if(fields!=null) {
			JaxInfo[] rv = new JaxInfo[fields.size()];
			fields.toArray(rv);
			return rv;
		} else {
			return null;
		}
	}
1213837
public void loadStructures(Set<Method> dynamicMethodsToWrite) {
		
	   	for (Field configuredField : getListOfFields(configuredClass)) {
		
	   		String targetFieldName = configReader.retrieveTargetFieldName(configuredField);
			
			if(targetFieldName == THE_FIELD_IS_NOT_CONFIGURED) continue;
				
			boolean isNestedMapping = isNestedMapping(targetFieldName);
			
			Field targetField = null;
			NestedMappingInfo nestedMappingInfo = null;
			
			if(isNestedMapping)
				try{	
					nestedMappingInfo = loadNestedMappingInformation(xml, targetClass, targetFieldName, sourceClass, destinationClass, configuredField);
				    targetField = nestedMappingInfo.getLastNestedField();
				}catch(InvalidNestedMappingException e){
				    // catch and rethrown the exception with more information
				    Error.invalidNestedMapping(configuredClass, configuredField, targetClass, e.getMessage(), e.getMessages().get(InvalidNestedMappingException.FIELD));}
			else
				targetField = retrieveField(targetClass,targetFieldName);
			
			
			MappedField configuredMappedField = new MappedField(configuredField);
			
			MappedField targetMappedField     = isNestedMapping ?nestedMappingInfo.getLastNestedMappedField()
					                                            :new MappedField(targetField);

			MappedField destinationMappedField = isDestConfigured?configuredMappedField:targetMappedField;
			MappedField sourceMappedField = isDestConfigured?targetMappedField:configuredMappedField;

			Field destinationField = isDestConfigured?configuredField:targetField;
			Field sourceField      = isDestConfigured?targetField:configuredField;
			
			//load and check the get/set custom methods of destination and source fields
			if(isNestedMapping)	configReader.loadAccessors(nestedMappingInfo.getLastNestedClass(),configuredMappedField, targetMappedField);
			else				configReader.loadAccessors(configuredMappedField, targetMappedField);
			
			boolean isUndefined = false;
			
			try{
				isUndefined = operationAnalyzer.isUndefined(destinationField, sourceField);
			}catch(Exception e){
				// catch and rethrown the exception with more information
				Error.badConversion(destinationField, destinationClass, sourceField, sourceClass,e.getMessage());
			}
			
			if(isUndefined)	
				Error.undefinedMapping(destinationField, destinationClass, sourceField, sourceClass);
			
			InfoOperation info = operationAnalyzer.getInfo();
			
			OperationType operationType = info.getOperationType();

			AGeneralOperation operation = OperationFactory.getOperation(operationType);
			
			if(operationType.isBasic())
				simpleOperations.add((ASimpleOperation) operation);	
				
			if(operationType.isComplex())
				complexOperations.add(((AComplexOperation) operation)
						.setDestinationClass(defineStructure(destinationMappedField.getValue(), sourceMappedField.getValue())));
			
 			if(operationType.isRecursive())
				((ARecursiveOperation) operation).setDynamicMethodsToWrite(dynamicMethodsToWrite)
				 							     .setXml(xml)
				                                 .setConfigChosen(isNull(info.getConfigChosen()) // if both classes are configured
										                    	  ?configurationChosen		     // returns the configuration chosen
												                  :info.getConfigChosen());      // else returns the configuration retrieved
			// common settings
			operation.setDestinationField(destinationMappedField)
					 .setSourceField(sourceMappedField)
					 .setInfoOperation(info)
					 .setNestedMappingInfo(nestedMappingInfo);
						
			
			boolean isAvoidSet = false;
			boolean isConversion = info.getOperationType().isAConversion();
			
			if(isConversion)
				isAvoidSet = conversionAnalyzer.getMethod().isAvoidSet();
			
			// verifies destination accessors only if isn't a nested field
			if(!isNestedMapping || !targetClass.equals(destinationClass))
				if(isAvoidSet)	verifyGetterMethods(destinationClass,destinationMappedField);
				else		verifiesAccessorMethods(destinationClass,destinationMappedField);
			
			// verifies source accessors only if isn't a nested field
			if(!isNestedMapping || !targetClass.equals(sourceClass))
				verifyGetterMethods(sourceClass,sourceMappedField);
				findSetterMethods(sourceClass,sourceMappedField);
			
			operation.avoidDestinationSet(isAvoidSet);

			if(isConversion){
				
				conversionHandler.load(conversionAnalyzer)
				                 .from(sourceMappedField).to(destinationMappedField);
				
				// in case of dynamic conversion
				if(conversionHandler.toBeCreated())
					dynamicMethodsToWrite.add(conversionHandler.loadMethod());
				
				operation.setConversionMethod(conversionHandler.getMethod())
						 .setMemberShip      (conversionHandler.getMembership());
			}
				
		}
		
		// checks if there isn't a correspondence between classes
		if(simpleOperations.isEmpty() && complexOperations.isEmpty())
				Error.absentRelationship(configuredClass, targetClass);	
	}
1009888
public void buildFieldHeader(XMLNode node, Content classContentTree) {
        if (currentClass.serializableFields().length > 0) {
            buildFieldSerializationOverview(currentClass, classContentTree);
        }
    }
1161448
@Override
    public R visitSerialField(SerialFieldTree node, P p) {
        R r = scan(node.getName(), p);
        r = scanAndReduce(node.getType(), p, r);
        r = scanAndReduce(node.getDescription(), p, r);
        return r;
    }
212915
public static FieldNode getField(ClassNode classNode, String fieldName) {
        ClassNode node = classNode;
        Set<String> visited = new HashSet<String>();
        while (node != null) {
            FieldNode fn = node.getDeclaredField(fieldName);
            if (fn != null) return fn;
            ClassNode[] interfaces = node.getInterfaces();
            for (ClassNode iNode : interfaces) {
                if (visited.contains(iNode.getName())) continue;
                FieldNode ifn = getField(iNode, fieldName);
                visited.add(iNode.getName());
                if (ifn != null) return ifn;
            }
            node = node.getSuperClass();
        }
        return null;
    }
1263726
public static final String getter(Field field, String fieldName)
    {
        Class<?> type = field.getType();
        if (type.isPrimitive() && "boolean".equals(type.getName()))
        {
            return isser(fieldName);
        }
        else
        {
            return getter(fieldName);
        }
    }
260133
int getFieldIndex(TypeElement declaringClass, String name, String descriptor)
    {
        String fullyQualifiedForm = declaringClass.getQualifiedName().toString();
        return getRefIndex(Fieldref.class, fullyQualifiedForm, name, descriptor);
    }