Converts property annotations to properties model.

@param propertyAnnotations propertyAnnotations
@param knowledgeNamespace knowledgeNamespace
@return model
771117
protected PropertiesModel toPropertiesModel(Property[] propertyAnnotations, KnowledgeNamespace knowledgeNamespace) {
        if (propertyAnnotations == null || propertyAnnotations.length == 0) {
            return null;
        }
        PropertiesModel propertiesModel = new V1PropertiesModel(knowledgeNamespace.uri());
        for (Property propertyAnnotation : propertyAnnotations) {
            PropertyModel propertyModel = new V1PropertyModel(knowledgeNamespace.uri());
            String name = propertyAnnotation.name();
            if (!UNDEFINED.equals(name)) {
                propertyModel.setName(name);
            }
            String value = propertyAnnotation.value();
            if (!UNDEFINED.equals(value)) {
                propertyModel.setValue(value);
            }
            propertiesModel.addProperty(propertyModel);
        }
        return propertiesModel;
    }
764009
private function propertyToField($propertyValue, AbstractField $annotation)
    {
        $fieldType = $annotation->type;
        switch ($fieldType) {
            case 'string':
                $fieldValue = strval($propertyValue);
                break;
            case 'bool':
                $fieldValue = boolval($propertyValue);
                break;
            case 'int':
                $fieldValue = intval($propertyValue);
                break;
            case 'float':
                $fieldValue = floatval($propertyValue);
                break;
            case 'array':
                $fieldValue = is_array($propertyValue) ? $propertyValue : (array)($propertyValue);
                break;
            case 'date':
                /** @var UTCDateTime $propertyValue */
                $fieldValue = ($propertyValue instanceof UTCDateTime) ? $propertyValue->toDateTime()->setTimezone(new \DateTimeZone(date_default_timezone_get())) : $propertyValue;
                break;
            case 'id':
                /** @var ObjectId $propertyValue */
                $fieldValue = $propertyValue;
                break;
            case 'embedOne':
                $fieldValue = $this->propertyToEmbedOne($propertyValue, $annotation);
                break;
            case 'embedMany':
                $fieldValue = $this->propertyToEmbedMany((array)$propertyValue, $annotation);
                break;
            case 'raw':
                $fieldValue = $propertyValue;
                break;
            default:
                $fieldValue = $propertyValue;
                break;
        }
        return $fieldValue;
    }
793688
public static String setter(TypeName beanClass, String beanName, ModelProperty property) {		
		if (property.getParent()!=null && ((ModelClass<?>) property.getParent()).isImmutablePojo()) {
			return ImmutableUtility.IMMUTABLE_PREFIX + property.getName();
		} else {
			String prefix=""; 
			if (beanName!=null) {
				prefix=beanName+".";
			}
			if (property.isPublicField()) {
				return prefix+property.getName();
			} else if (property.isFieldWithSetter()) {
				return prefix+"set" + converterField2Method.convert(property.getName());
			} else {				
				throw new PropertyVisibilityException(String.format("property '%s' of class '%s' can not be modify",
						property.getName(), property.getParent().getElement().asType()));
			}
		}
	}
590615
public final String toAnnotationString(Nullability nullability) {
    return nullability == Nullability.EXPLICIT
        ? appendAsNonNull(new StringBuilder(), true).toString()
        : appendTo(new StringBuilder(), true).toString();
  }
1285851
@Deprecated
  public ProjectDefinition setProperties(Properties properties) {
    for (Entry<Object, Object> entry : properties.entrySet()) {
      this.properties.put(entry.getKey().toString(), entry.getValue().toString());
    }
    return this;
  }
265075
protected LoggersModel toLoggersModel(Logger[] loggerAnnotations, KnowledgeNamespace knowledgeNamespace) {
        if (loggerAnnotations == null || loggerAnnotations.length == 0) {
            return null;
        }
        LoggersModel loggersModel = new V1LoggersModel(knowledgeNamespace.uri());
        for (Logger loggerAnnotation : loggerAnnotations) {
            LoggerModel loggerModel = new V1LoggerModel(knowledgeNamespace.uri());
            int interval = loggerAnnotation.interval();
            if (interval > -1) {
                loggerModel.setInterval(interval);
            }
            String log = loggerAnnotation.log();
            if (!UNDEFINED.equals(log)) {
                loggerModel.setLog(log);
            }
            LoggerType loggerType = loggerAnnotation.type();
            if (!LoggerType.THREADED_FILE.equals(loggerType)) {
                loggerModel.setType(loggerType);
            }
            loggersModel.addLogger(loggerModel);
        }
        return loggersModel;
    }
304087
private MethodMetadata<?, ?> createPropertyMethodMetadata(AnnotatedType annotatedType, PropertyMethod propertyMethod) {
        MethodMetadata<?, ?> methodMetadata;
        Class<?> propertyType = propertyMethod.getType();
        if (Collection.class.isAssignableFrom(propertyType)) {
            Type genericType = propertyMethod.getGenericType();
            ParameterizedType type = (ParameterizedType) genericType;
            Class<?> elementType;
            Type typeArgument = type.getActualTypeArguments()[0];
            if (typeArgument instanceof Class) {
                elementType = (Class<?>) typeArgument;
            } else if (typeArgument instanceof ParameterizedType) {
                ParameterizedType parameterizedTypeArgument = (ParameterizedType) typeArgument;
                elementType = (Class<?>) parameterizedTypeArgument.getRawType();
            } else if (typeArgument instanceof TypeVariable<?>) {
                TypeVariable<?> typeVariable = (TypeVariable<?>) typeArgument;
                Type[] bounds = typeVariable.getBounds();
                if (bounds.length != 1) {
                    throw new XOException("Cannot determine boundary of " + typeVariable.getName() + " of collection property "
                            + propertyMethod.getAnnotatedElement().toGenericString());
                }
                elementType = (Class<?>) bounds[0];
            } else {
                throw new XOException("Cannot determine argument type of collection property " + propertyMethod.getAnnotatedElement().toGenericString());
            }
            AnnotatedType annotatedTypeArgument = new AnnotatedType(elementType);
            if (isEntityType(annotatedTypeArgument)) {
                Direction relationDirection = getRelationDirection(propertyMethod, Direction.FROM);
                com.buschmais.xo.spi.reflection.AnnotatedElement<?> relationElement = getRelationDefinitionElement(propertyMethod);
                RelationTypeMetadata relationshipType = new RelationTypeMetadata<>(metadataFactory.createRelationMetadata(relationElement, metadataByType));
                methodMetadata = new EntityCollectionPropertyMethodMetadata<>(propertyMethod, relationshipType, relationDirection,
                        metadataFactory.createCollectionPropertyMetadata(propertyMethod));
            } else if (isRelationType(annotatedTypeArgument)) {
                TypeMetadata relationTypeMetadata = getOrCreateTypeMetadata(elementType);
                RelationTypeMetadata<RelationMetadata> relationMetadata = (RelationTypeMetadata) relationTypeMetadata;
                Direction relationDirection = getRelationDirection(annotatedType, propertyMethod, relationTypeMetadata, relationMetadata);
                methodMetadata = new RelationCollectionPropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection,
                        metadataFactory.createCollectionPropertyMetadata(propertyMethod));
            } else {
                throw new XOException("Unsupported type argument '" + elementType.getName() + "' for collection property: " + propertyType.getName());
            }
        } else if (annotatedMethods.containsKey(propertyType)) {
            AnnotatedType referencedType = new AnnotatedType(propertyType);
            Direction relationDirection;
            RelationTypeMetadata<RelationMetadata> relationMetadata;
            if (isEntityType(referencedType)) {
                relationDirection = getRelationDirection(propertyMethod, Direction.FROM);
                com.buschmais.xo.spi.reflection.AnnotatedElement<?> relationElement = getRelationDefinitionElement(propertyMethod);
                relationMetadata = new RelationTypeMetadata<>(metadataFactory.createRelationMetadata(relationElement, metadataByType));
                methodMetadata = new EntityReferencePropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection,
                        metadataFactory.createReferencePropertyMetadata(propertyMethod));
            } else if (isRelationType(referencedType)) {
                TypeMetadata relationTypeMetadata = getOrCreateTypeMetadata(propertyType);
                relationMetadata = (RelationTypeMetadata) relationTypeMetadata;
                relationDirection = getRelationDirection(annotatedType, propertyMethod, relationTypeMetadata, relationMetadata);
                methodMetadata = new RelationReferencePropertyMethodMetadata<>(propertyMethod, relationMetadata, relationDirection,
                        metadataFactory.createReferencePropertyMetadata(propertyMethod));
            } else {
                throw new XOException("Unsupported type for reference property: " + propertyType.getName());
            }
        } else {
            methodMetadata = new PrimitivePropertyMethodMetadata<>(propertyMethod, metadataFactory.createPropertyMetadata(propertyMethod));
        }
        return methodMetadata;
    }
963580
protected FaultsModel toFaultsModel(Fault[] faults, KnowledgeNamespace knowledgeNamespace) {
        FaultsModel faultsModel = null;
        if (faults != null) {
            for (Fault fault : faults) {
                if (fault != null) {
                    FaultModel faultModel = new V1FaultModel(knowledgeNamespace.uri());
                    String from = fault.from();
                    if (!UNDEFINED.equals(from)) {
                        faultModel.setFrom(from);
                    }
                    String to = fault.to();
                    if (!UNDEFINED.equals(to)) {
                        faultModel.setTo(to);
                    }
                    if (faultsModel == null) {
                        faultsModel = new V1FaultsModel(knowledgeNamespace.uri());
                    }
                    faultsModel.addFault(faultModel);
                }
            }
        }
        return faultsModel;
    }
179697
private function convertReflectionPropertyToManyToOneAssociationMetadata(
        ReflectionProperty $reflectionProperty,
        array $propertyAnnotations,
        Mapping\ClassMetadata $metadata
    ) {
        $className      = $metadata->getClassName();
        $fieldName      = $reflectionProperty->getName();
        $manyToOneAnnot = $propertyAnnotations[Annotation\ManyToOne::class];
        $assocMetadata  = new Mapping\ManyToOneAssociationMetadata($fieldName);
        $targetEntity   = $manyToOneAnnot->targetEntity;

        $assocMetadata->setTargetEntity($targetEntity);
        $assocMetadata->setCascade($this->getCascade($className, $fieldName, $manyToOneAnnot->cascade));
        $assocMetadata->setFetchMode($this->getFetchMode($className, $manyToOneAnnot->fetch));

        if (! empty($manyToOneAnnot->inversedBy)) {
            $assocMetadata->setInversedBy($manyToOneAnnot->inversedBy);
        }

        // Check for Id
        if (isset($propertyAnnotations[Annotation\Id::class])) {
            $assocMetadata->setPrimaryKey(true);
        }

        $this->attachAssociationPropertyCache($propertyAnnotations, $reflectionProperty, $assocMetadata, $metadata);

        // Check for JoinColumn/JoinColumns annotations
        switch (true) {
            case isset($propertyAnnotations[Annotation\JoinColumn::class]):
                $joinColumnAnnot = $propertyAnnotations[Annotation\JoinColumn::class];

                $assocMetadata->addJoinColumn(
                    $this->convertJoinColumnAnnotationToJoinColumnMetadata($joinColumnAnnot)
                );

                break;

            case isset($propertyAnnotations[Annotation\JoinColumns::class]):
                $joinColumnsAnnot = $propertyAnnotations[Annotation\JoinColumns::class];

                foreach ($joinColumnsAnnot->value as $joinColumnAnnot) {
                    $assocMetadata->addJoinColumn(
                        $this->convertJoinColumnAnnotationToJoinColumnMetadata($joinColumnAnnot)
                    );
                }

                break;
        }

        return $assocMetadata;
    }
1254119
public static Config parse(Properties properties) {
        ConfigBuilder config = new SimpleConfig();
        for (Object o : new TreeSet<>(properties.keySet())) {
            String key = o.toString();
            if (isPositional(key)) {
                String entryKey = entryKey(key);
                if (config.containsKey(entryKey)) {
                    config.getCollection(entryKey).add(properties.getProperty(key));
                } else {
                    ArrayList<Object> sequence = new ArrayList<>();
                    sequence.add(properties.getProperty(key));
                    config.putCollection(entryKey, sequence);
                }
            } else {
                config.put(key, properties.getProperty(key));
            }
        }
        return ImmutableConfig.copyOf(config);
    }
743452
public static Map<String, CmsProperty> toObjectMap(Iterable<CmsProperty> properties) {

        Map<String, CmsProperty> result = new LinkedHashMap<String, CmsProperty>();
        for (CmsProperty property : properties) {
            result.put(property.getName(), property);
        }
        return result;
    }
121290
private void addMemberProperties(
      AnnotationTypeDeclaration node, List<AnnotationTypeMemberDeclaration> members,
      Map<ExecutableElement, VariableElement> fieldElements) {
    if (members.isEmpty()) {
      return;
    }
    StringBuilder propertyDecls = new StringBuilder();
    StringBuilder propertyImpls = new StringBuilder();
    for (AnnotationTypeMemberDeclaration member : members) {
      ExecutableElement memberElement = member.getExecutableElement();
      String propName = NameTable.getAnnotationPropertyName(memberElement);
      String memberTypeStr = nameTable.getObjCType(memberElement.getReturnType());

      String fieldName = nameTable.getVariableShortName(fieldElements.get(memberElement));
      propertyDecls.append(UnicodeUtils.format("@property (readonly) %s%s%s;\n",
          memberTypeStr, memberTypeStr.endsWith("*") ? "" : " ", propName));
      if (NameTable.needsObjcMethodFamilyNoneAttribute(propName)) {
        propertyDecls.append(UnicodeUtils.format(
            "- (%s)%s OBJC_METHOD_FAMILY_NONE;\n", memberTypeStr, propName));
      }
      propertyImpls.append(UnicodeUtils.format("@synthesize %s = %s;\n", propName, fieldName));
    }
    node.addBodyDeclaration(NativeDeclaration.newInnerDeclaration(
        propertyDecls.toString(), propertyImpls.toString()));
  }
135088
protected static TypedPropertyDescriptor _buildPropertyDescriptor(
    String propertyName, Class beanClass, String getterName, String setterName )
  {
    try
    {
      return new TypedPropertyDescriptor( propertyName, beanClass, getterName, setterName );
    }
    catch( IntrospectionException e )
    {
      throw new RuntimeException( "Failed to create property \"" + propertyName + "\" on class \"" + beanClass +
                                  "\": " + e.getClass() + " - " + e.getMessage() );
    }
  }
535603
protected GlobalsModel toGlobalsModel(Global[] globals, KnowledgeNamespace knowledgeNamespace) {
        GlobalsModel globalsModel = null;
        if (globals != null) {
            for (Global global : globals) {
                if (global != null) {
                    GlobalModel globalModel = new V1GlobalModel(knowledgeNamespace.uri());
                    String from = global.from();
                    if (!UNDEFINED.equals(from)) {
                        globalModel.setFrom(from);
                    }
                    String to = global.to();
                    if (!UNDEFINED.equals(to)) {
                        globalModel.setTo(to);
                    }
                    if (globalsModel == null) {
                        globalsModel = new V1GlobalsModel(knowledgeNamespace.uri());
                    }
                    globalsModel.addGlobal(globalModel);
                }
            }
        }
        return globalsModel;
    }
980053
private function convertPropertyAnnotationsToProperty(
        array $propertyAnnotations,
        ReflectionProperty $reflectionProperty,
        Mapping\ClassMetadata $metadata
    ) : ?Mapping\Property {
        switch (true) {
            case isset($propertyAnnotations[Annotation\Column::class]):
                return $this->convertReflectionPropertyToFieldMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\OneToOne::class]):
                return $this->convertReflectionPropertyToOneToOneAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\ManyToOne::class]):
                return $this->convertReflectionPropertyToManyToOneAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\OneToMany::class]):
                return $this->convertReflectionPropertyToOneToManyAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\ManyToMany::class]):
                return $this->convertReflectionPropertyToManyToManyAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\Embedded::class]):
                return null;
            default:
                return new Mapping\TransientMetadata($reflectionProperty->getName());
        }
    }
1187843
public Bindable<T> withAnnotations(Annotation... annotations) {
		return new Bindable<>(this.type, this.boxedType, this.value,
				(annotations != null) ? annotations : NO_ANNOTATIONS);
	}
518034
public PropertiesBuilder set(String propertyName, Object propertyValue) {
    return set(propertyName, String.valueOf(propertyValue));
  }