当前位置: 首页>>代码示例>>Java>>正文


Java Space类代码示例

本文整理汇总了Java中com.contentful.vault.Space的典型用法代码示例。如果您正苦于以下问题:Java Space类的具体用法?Java Space怎么用?Java Space使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Space类属于com.contentful.vault包,在下文中一共展示了Space类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSupportedAnnotationTypes

import com.contentful.vault.Space; //导入依赖的package包/类
@Override public Set<String> getSupportedAnnotationTypes() {
  Set<String> types = new LinkedHashSet<>();
  types.add(ContentType.class.getCanonicalName());
  types.add(Space.class.getCanonicalName());
  return types;
}
 
开发者ID:contentful,项目名称:vault,代码行数:7,代码来源:Processor.java

示例2: parseSpace

import com.contentful.vault.Space; //导入依赖的package包/类
private void parseSpace(TypeElement element, Map<TypeElement, SpaceInjection> spaces,
    Map<TypeElement, ModelInjection> models) {
  Space annotation = element.getAnnotation(Space.class);
  String id = annotation.value();
  if (id.isEmpty()) {
    error(element, "@%s id may not be empty. (%s)",
        Space.class.getSimpleName(),
        element.getQualifiedName());
    return;
  }

  TypeMirror spaceMirror = elementUtils.getTypeElement(Space.class.getName()).asType();
  List<ModelInjection> includedModels = new ArrayList<>();
  for (AnnotationMirror mirror : element.getAnnotationMirrors()) {
    if (typeUtils.isSameType(mirror.getAnnotationType(), spaceMirror)) {
      Set<? extends Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> items =
          mirror.getElementValues().entrySet();

      for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : items) {
        if ("models".equals(entry.getKey().getSimpleName().toString())) {
          List l = (List) entry.getValue().getValue();
          if (l.size() == 0) {
            error(element, "@%s models must not be empty. (%s)",
                Space.class.getSimpleName(),
                element.getQualifiedName());
            return;
          }

          Set<String> modelIds = new LinkedHashSet<>();
          for (Object model : l) {
            TypeElement e = (TypeElement) ((Type) ((Attribute) model).getValue()).asElement();
            ModelInjection modelInjection = models.get(e);
            if (modelInjection == null) {
              return;
            } else {
              String rid = modelInjection.remoteId;
              if (!modelIds.add(rid)) {
                error(element, "@%s includes multiple models with the same id \"%s\". (%s)",
                    Space.class.getSimpleName(), rid, element.getQualifiedName());
                return;
              }
              includedModels.add(modelInjection);
            }
          }
        }
      }
    }
  }

  List<String> locales = Arrays.asList(annotation.locales());
  Set<String> checked = new HashSet<>();
  for (int i = locales.size() - 1; i >= 0; i--) {
    String code = locales.get(i);
    if (!checked.add(code)) {
      error(element, "@%s contains duplicate locale code '%s'. (%s)",
          Space.class.getSimpleName(), code, element.getQualifiedName());
      return;
    } else if (code.contains(" ") || code.isEmpty()) {
      error(element, "Invalid locale code '%s', must not be empty and may not contain spaces. (%s)",
          code, element.getQualifiedName());
      return;
    }
  }
  if (checked.size() == 0) {
    error(element, "@%s at least one locale must be configured. (%s)",
        Space.class.getSimpleName(), element.getQualifiedName());
    return;
  }

  ClassName injectionClassName = getInjectionClassName(element, SUFFIX_SPACE);
  String dbName = "space_" + SqliteUtils.hashForId(id);
  String copyPath = StringUtils.defaultIfBlank(annotation.copyPath(), null);
  spaces.put(element, new SpaceInjection(id, injectionClassName, element, includedModels, dbName,
      annotation.dbVersion(), copyPath, locales));
}
 
开发者ID:contentful,项目名称:vault,代码行数:76,代码来源:Processor.java


注:本文中的com.contentful.vault.Space类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。