コード例 #1
0
ファイル: MetaModelRow.java プロジェクト: n0way/isis
 private static String interpretFacet(final Facet facet) {
   if (facet == null || facet.isNoop()) {
     return "";
   }
   if (facet instanceof ImperativeFacet) {
     ImperativeFacet imperativeFacet = (ImperativeFacet) facet;
     return imperativeFacet.getMethods().get(0).getName();
   }
   final String name = facet.getClass().getSimpleName();
   if (ignore(name)) {
     return "";
   }
   final String abbr = StringExtensions.toAbbreviation(name);
   return abbr.length() > 0 ? abbr : name;
 }
コード例 #2
0
ファイル: IsisMatchers.java プロジェクト: DINKIN/estatio
  @Factory
  public static Matcher<String> endsWithStripNewLines(final String expected) {
    final String strippedExpected = StringExtensions.stripNewLines(expected);
    return new StringEndsWith(strippedExpected) {
      @Override
      public boolean matchesSafely(final String actual) {
        return super.matchesSafely(StringExtensions.stripNewLines(actual));
      }

      @Override
      public void describeTo(final Description description) {
        description
            .appendText("a string (ignoring new lines) ending with")
            .appendValue(strippedExpected);
      }
    };
  }
コード例 #3
0
ファイル: IsisMatchers.java プロジェクト: DINKIN/estatio
  @Factory
  public static Matcher<String> equalToStripNewLines(final String expected) {
    final String strippedExpected = StringExtensions.stripNewLines(expected);
    return new IsEqual<String>(strippedExpected) {
      @Override
      public boolean matches(final Object actualObj) {
        final String actual = (String) actualObj;
        return super.matches(StringExtensions.stripNewLines(actual));
      }

      @Override
      public void describeTo(final Description description) {
        description
            .appendText("a string (ignoring new lines) equal to")
            .appendValue(strippedExpected);
      }
    };
  }
コード例 #4
0
  private void attachDisabledFacetIfDisabledMethodIsFound(
      final ProcessMethodContext processMethodContext) {

    final Method method = processMethodContext.getMethod();
    final String capitalizedName =
        StringExtensions.asJavaBaseNameStripAccessorPrefixIfRequired(method.getName());

    final Class<?> cls = processMethodContext.getCls();
    // search for exact match
    Method disableMethod =
        MethodFinderUtils.findMethod(
            cls,
            MethodScope.OBJECT,
            MethodPrefixConstants.DISABLE_PREFIX + capitalizedName,
            new Class<?>[] {String.class, TranslatableString.class},
            method.getParameterTypes());
    if (disableMethod == null) {
      // search for no-arg version
      disableMethod =
          MethodFinderUtils.findMethod(
              cls,
              MethodScope.OBJECT,
              MethodPrefixConstants.DISABLE_PREFIX + capitalizedName,
              new Class<?>[] {String.class, TranslatableString.class},
              new Class<?>[0]);
    }
    if (disableMethod == null) {
      return;
    }

    processMethodContext.removeMethod(disableMethod);

    final FacetHolder facetHolder = processMethodContext.getFacetHolder();
    final TranslationService translationService =
        this.servicesInjector.lookupService(TranslationService.class);
    // sadness: same logic as in I18nFacetFactory
    final String translationContext =
        ((IdentifiedHolder) facetHolder).getIdentifier().toClassAndNameIdentityString();
    FacetUtil.addFacet(
        new DisableForContextFacetViaMethod(
            disableMethod, translationService, translationContext, facetHolder));
  }
コード例 #5
0
  @Override
  public void process(final ProcessMethodContext processMethodContext) {
    final Method getMethod = processMethodContext.getMethod();
    final String capitalizedName =
        StringExtensions.asJavaBaseNameStripAccessorPrefixIfRequired(getMethod.getName());

    final Class<?> cls = processMethodContext.getCls();
    final Method notInServiceMenuMethod =
        MethodFinderUtils.findMethod(
            cls,
            MethodScope.OBJECT,
            "notInServiceMenu" + capitalizedName,
            boolean.class,
            new Class[] {});
    if (notInServiceMenuMethod == null) {
      return;
    }

    processMethodContext.removeMethod(notInServiceMenuMethod);

    final FacetHolder facetedMethod = processMethodContext.getFacetHolder();
    FacetUtil.addFacet(new NotInServiceMenuFacetMethod(notInServiceMenuMethod, facetedMethod));
  }
コード例 #6
0
 public String getWicketId() {
   return StringExtensions.toCamelCase(name());
 }