private static void parseObjectTypeDefsFromSchemaHandling(
      RefinedResourceSchemaImpl rSchema,
      ResourceType resourceType,
      SchemaHandlingType schemaHandling,
      Collection<ResourceObjectTypeDefinitionType> resourceObjectTypeDefs,
      ShadowKindType impliedKind,
      PrismContext prismContext,
      String contextDescription)
      throws SchemaException {

    if (resourceObjectTypeDefs == null) {
      return;
    }

    Map<ShadowKindType, RefinedObjectClassDefinition> defaults = new HashMap<>();

    for (ResourceObjectTypeDefinitionType accountTypeDefType : resourceObjectTypeDefs) {
      RefinedObjectClassDefinition rOcDef =
          RefinedObjectClassDefinitionImpl.parse(
              accountTypeDefType,
              resourceType,
              rSchema,
              impliedKind,
              prismContext,
              contextDescription);

      if (rOcDef.isDefault()) {
        if (defaults.containsKey(rOcDef.getKind())) {
          throw new SchemaException(
              "More than one default "
                  + rOcDef.getKind()
                  + " definitions ("
                  + defaults.get(rOcDef.getKind())
                  + ", "
                  + rOcDef
                  + ") in "
                  + contextDescription);
        } else {
          defaults.put(rOcDef.getKind(), rOcDef);
        }
      }

      rSchema.add(rOcDef);
    }
  }
  private static void parseObjectTypesFromSchema(
      RefinedResourceSchemaImpl rSchema,
      ResourceType resourceType,
      PrismContext prismContext,
      String contextDescription)
      throws SchemaException {

    RefinedObjectClassDefinition rAccountDefDefault = null;
    for (ObjectClassComplexTypeDefinition objectClassDef :
        rSchema.getOriginalResourceSchema().getObjectClassDefinitions()) {
      QName objectClassname = objectClassDef.getTypeName();
      if (rSchema.getRefinedDefinition(objectClassname) != null) {
        continue;
      }
      RefinedObjectClassDefinition rOcDef =
          RefinedObjectClassDefinitionImpl.parseFromSchema(
              objectClassDef,
              resourceType,
              rSchema,
              prismContext,
              "object class " + objectClassname + ", in " + contextDescription);

      if (objectClassDef.getKind() == ShadowKindType.ACCOUNT && rOcDef.isDefault()) {
        if (rAccountDefDefault == null) {
          rAccountDefDefault = rOcDef;
        } else {
          throw new SchemaException(
              "More than one default account definitions ("
                  + rAccountDefDefault
                  + ", "
                  + rOcDef
                  + ") in "
                  + contextDescription);
        }
      }

      rSchema.add(rOcDef);
    }
  }