Example usage for org.apache.commons.lang3 StringUtils deleteWhitespace

List of usage examples for org.apache.commons.lang3 StringUtils deleteWhitespace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils deleteWhitespace.

Prototype

public static String deleteWhitespace(final String str) 

Source Link

Document

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

 StringUtils.deleteWhitespace(null)         = null StringUtils.deleteWhitespace("")           = "" StringUtils.deleteWhitespace("abc")        = "abc" StringUtils.deleteWhitespace("   ab  c  ") = "abc" 

Usage

From source file:org.libreplan.web.common.components.finders.TaskGroupsMultipleFiltersFinder.java

private void searchInResources(String filter) {
    Map<Class<?>, List<Resource>> mapResources = databaseSnapshots.snapshotMapResources();
    for (Class<?> className : mapResources.keySet()) {
        for (Resource resource : mapResources.get(className)) {
            String name = StringUtils.deleteWhitespace(resource.getName().toLowerCase());

            if (name.contains(filter)) {
                addResource(className, resource);

                if ((filter.length() < 3) && (getListMatching().size() > 9)) {
                    return;
                }//from  w w w.j a va  2  s  .  c  o m
            }
        }
    }
}

From source file:org.libreplan.web.materials.MaterialsModel.java

private boolean equalsMaterialCategory(MaterialCategory obj1, MaterialCategory obj2) {
    String name1 = StringUtils.deleteWhitespace(obj1.getName().toLowerCase());
    String name2 = StringUtils.deleteWhitespace(obj2.getName().toLowerCase());

    return name1.equals(name2);
}

From source file:org.massyframework.modules.launching.DefaultAssemblyResourceLoader.java

protected List<ClassLoader> parserClassLoader(String identifiers) throws ModuleLoadException {
    List<ClassLoader> result = new ArrayList<ClassLoader>();
    if (identifiers != null) {
        String[] names = StringUtils.split(identifiers, ",");
        for (String name : names) {
            name = StringUtils.deleteWhitespace(name);
            if (!"".equals(name)) {
                int index = StringUtils.indexOf(name, ":");
                String moduleName = name;
                String slot = "main";
                if (index != -1) {
                    moduleName = StringUtils.substring(name, 0, index);
                    slot = StringUtils.substring(name, index + 1, name.length());
                }/*w ww .ja  v  a  2  s . c om*/
                ModuleIdentifier identifier = ModuleIdentifier.create(moduleName, slot);
                Module module = this.moduleLoader.loadModule(identifier);
                result.add(module.getClassLoader());
            }
        }
    }

    return result;
}

From source file:org.opendaylight.controller.cluster.datastore.DatastoreContextIntrospector.java

private static String convertToCamelCase(String inString) {
    String str = inString.trim();
    if (StringUtils.contains(str, '-') || StringUtils.contains(str, ' ')) {
        str = inString.replace('-', ' ');
        str = WordUtils.capitalizeFully(str);
        str = StringUtils.deleteWhitespace(str);
    }/*  w  ww  .ja v a2  s  . com*/

    return StringUtils.uncapitalize(str);
}

From source file:org.primefaces.extensions.component.sheet.Sheet.java

/**
 * Gets the row key value as a String suitable for use in javascript rendering.
 *
 * @param context/* w ww  .j av a  2 s . c  o  m*/
 * @return
 */
protected String getRowKeyValueAsString(final Object key) {
    // TODO for now just use toString and remove spaces/etc, but in future
    // we'll want to revisit this to support complex key objects
    final String result = key.toString();
    return "r_" + StringUtils.deleteWhitespace(result);
}

From source file:org.sleuthkit.autopsy.timeline.db.SQLHelper.java

/**
 * get the SQL where clause corresponding to the given filter
 *
 * uses instance of to dispatch to the correct method for each filter type.
 * NOTE: I don't like this if-else instance of chain, but I can't decide
 * what to do instead -jm/*w w  w.  j ava 2 s  .c  o m*/
 *
 * @param filter a filter to generate the SQL where clause for
 *
 * @return an SQL where clause (without the "where") corresponding to the
 *         filter
 */
private static String getSQLWhere(Filter filter) {
    String result = "";
    if (filter == null) {
        return "1";
    } else if (filter instanceof DescriptionFilter) {
        result = getSQLWhere((DescriptionFilter) filter);
    } else if (filter instanceof TagsFilter) {
        result = getSQLWhere((TagsFilter) filter);
    } else if (filter instanceof HashHitsFilter) {
        result = getSQLWhere((HashHitsFilter) filter);
    } else if (filter instanceof DataSourceFilter) {
        result = getSQLWhere((DataSourceFilter) filter);
    } else if (filter instanceof DataSourcesFilter) {
        result = getSQLWhere((DataSourcesFilter) filter);
    } else if (filter instanceof HideKnownFilter) {
        result = getSQLWhere((HideKnownFilter) filter);
    } else if (filter instanceof HashHitsFilter) {
        result = getSQLWhere((HashHitsFilter) filter);
    } else if (filter instanceof TextFilter) {
        result = getSQLWhere((TextFilter) filter);
    } else if (filter instanceof TypeFilter) {
        result = getSQLWhere((TypeFilter) filter);
    } else if (filter instanceof IntersectionFilter) {
        result = getSQLWhere((IntersectionFilter) filter);
    } else if (filter instanceof UnionFilter) {
        result = getSQLWhere((UnionFilter) filter);
    } else {
        throw new IllegalArgumentException(
                "getSQLWhere not defined for " + filter.getClass().getCanonicalName());
    }
    result = StringUtils.deleteWhitespace(result).equals("(1and1and1)") ? "1" : result; //NON-NLS
    result = StringUtils.deleteWhitespace(result).equals("()") ? "1" : result;
    return result;
}

From source file:org.sleuthkit.autopsy.timeline.events.db.EventDB.java

private static String getSQLWhere(Filter filter) {
    //TODO: this is here so that the filters don't depend, even implicitly, on the db, but it leads to some nasty code
    //it would all be much easier if all the getSQLWhere methods where moved to their respective filter classes
    String result = "";
    if (filter == null) {
        return "1";
    } else if (filter instanceof HideKnownFilter) {
        result = getSQLWhere((HideKnownFilter) filter);
    } else if (filter instanceof TextFilter) {
        result = getSQLWhere((TextFilter) filter);
    } else if (filter instanceof TypeFilter) {
        result = getSQLWhere((TypeFilter) filter);
    } else if (filter instanceof IntersectionFilter) {
        result = getSQLWhere((IntersectionFilter) filter);
    } else if (filter instanceof UnionFilter) {
        result = getSQLWhere((UnionFilter) filter);
    } else {/*from  w ww .ja v a  2 s  . c o m*/
        return "1";
    }
    result = StringUtils.deleteWhitespace(result).equals("(1and1and1)") ? "1" : result; // NON-NLS
    //System.out.println(result);
    return result;
}

From source file:org.tightblog.ui.restapi.InstallerController.java

@RequestMapping(value = "/create")
public ModelAndView createDatabaseTables(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    if (dynamicProperties.isDatabaseReady()) {
        response.sendRedirect(request.getContextPath() + "/");
        return null;
    }/*from  w w w.  j a va2s.  c  o  m*/
    Map<String, Object> map = initializeMap();
    List<String> messageList = new ArrayList<>(100);
    map.put("messages", messageList);

    String scriptPath = "";
    try (Connection conn = tbDataSource.getConnection()) {
        scriptPath = "/dbscripts/"
                + StringUtils.deleteWhitespace(conn.getMetaData().getDatabaseProductName().toLowerCase())
                + "-createdb.sql";
        messageList.add("Running database script: " + scriptPath);
        ClassPathResource script = new ClassPathResource(scriptPath);
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator(false, true, null, script);
        populator.populate(conn);
        messageList.add("Script ran without error");
        map.put("status", StartupStatus.needsBootstrapping);
    } catch (ScriptException | SQLException ex) {
        messageList.add("ERROR processing database script " + scriptPath);
        messageList.add(ex.getMessage());
        map.put("status", StartupStatus.databaseCreateError);
    }

    return new ModelAndView(".install", map);
}

From source file:org.wrml.runtime.schema.generator.SchemaGenerator.java

private void generateBeanAccessorMethods(final JavaBytecodeClass javaBytecodeClass, final Schema schema,
        final boolean isAggregate, final Slot slot) {

    final String slotName = slot.getName();
    final Value slotValue = slot.getValue();
    final JavaBytecodeType type = getSlotType(javaBytecodeClass, schema, isAggregate, slot);

    /*//from   ww w  .  j a v a2  s.  com
     * Following JavaBean property conventions, the suffix (end) of the
     * property accessor's method name will be the WRML schema slot's
     * name as mixed upper case.
     */
    final String methodNameSuffix = StringUtils.capitalize(StringUtils.deleteWhitespace(slotName));
    final String readMethodNamePrefix = (slotValue instanceof BooleanValue) ? JavaBean.IS : JavaBean.GET;
    final String readMethodName = readMethodNamePrefix + methodNameSuffix;

    JavaBytecodeAnnotation aliasAnnotation = null;
    JavaBytecodeAnnotation descriptionAnnotation = null;
    JavaBytecodeAnnotation titleAnnotation = null;
    JavaBytecodeAnnotation defaultValueAnnotation = null;

    final List<String> aliases = slot.getAliases();
    if (aliases != null && aliases.size() > 0) {
        aliasAnnotation = new JavaBytecodeAnnotation(SchemaGenerator.ANNOTATION_INTERNAL_NAME_ALIASES);
        final String[] aliasesArray = new String[aliases.size()];
        aliasAnnotation.setAttributeValue(AnnotationParameterName.value.name(), aliases.toArray(aliasesArray));
    }

    final String descriptionString = slot.getDescription();
    if (descriptionString != null && !descriptionString.isEmpty()) {
        descriptionAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_DESCRIPTION);
        descriptionAnnotation.setAttributeValue(AnnotationParameterName.value.name(), descriptionString);
    }

    final String titleString = slot.getTitle();
    if (titleString != null && !titleString.isEmpty()) {
        titleAnnotation = new JavaBytecodeAnnotation(SchemaGenerator.ANNOTATION_INTERNAL_NAME_TITLE);
        titleAnnotation.setAttributeValue(AnnotationParameterName.value.name(), titleString);
    }

    final String defaultValueString = getDefaultValueString(slotValue);
    if (defaultValueString != null && !defaultValueString.isEmpty()) {
        defaultValueAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_DEFAULT_VALUE);
        defaultValueAnnotation.setAttributeValue(AnnotationParameterName.value.name(), defaultValueString);
    }

    JavaBytecodeAnnotation disallowedValuesAnnotation = null;
    JavaBytecodeAnnotation divisibleByAnnotation = null;
    JavaBytecodeAnnotation maximumLengthAnnotation = null;
    JavaBytecodeAnnotation maximumSizeAnnotation = null;
    JavaBytecodeAnnotation maximumValueAnnotation = null;
    JavaBytecodeAnnotation minimumLengthAnnotation = null;
    JavaBytecodeAnnotation minimumSizeAnnotation = null;
    JavaBytecodeAnnotation minimumValueAnnotation = null;
    JavaBytecodeAnnotation multilineAnnotation = null;

    JavaBytecodeAnnotation collectionSlotAnnotation = null;

    if (slotValue.containsSlotValue(Value.SLOT_NAME_DISALLOWED_VALUES)) {

        final List<?> disallowedValues = (List<?>) slotValue.getSlotValue(Value.SLOT_NAME_DISALLOWED_VALUES);
        if (disallowedValues != null && disallowedValues.size() > 0) {
            disallowedValuesAnnotation = new JavaBytecodeAnnotation(
                    SchemaGenerator.ANNOTATION_INTERNAL_NAME_DISALLOWED_VALUES);

            final String[] values = new String[disallowedValues.size()];

            for (int i = 0; i < values.length; i++) {
                values[i] = String.valueOf(disallowedValues.get(i));
            }

            disallowedValuesAnnotation.setAttributeValue(AnnotationParameterName.value.name(), values);

        }

    }

    if (slotValue.containsSlotValue(TextValue.SLOT_NAME_MULTILINE) && slotValue instanceof TextValue) {
        final boolean isMultiline = (boolean) slotValue.getSlotValue(TextValue.SLOT_NAME_MULTILINE);
        if (isMultiline) {
            multilineAnnotation = new JavaBytecodeAnnotation(
                    SchemaGenerator.ANNOTATION_INTERNAL_NAME_MULTILINE);
        }
    }

    if (slotValue.containsSlotValue(NumericValue.SLOT_NAME_DIVISIBLE_BY)
            && (slotValue instanceof IntegerValue || slotValue instanceof LongValue)) {
        divisibleByAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_DIVISIBLE_BY_VALUE);
        divisibleByAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                String.valueOf(slotValue.getSlotValue(NumericValue.SLOT_NAME_DIVISIBLE_BY)));

    }

    // Maximum values

    if (slotValue.containsSlotValue(TextValue.SLOT_NAME_MAXIMUM_LENGTH) && slotValue instanceof TextValue) {
        maximumLengthAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MAXIMUM_LENGTH);
        maximumLengthAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                (int) slotValue.getSlotValue(TextValue.SLOT_NAME_MAXIMUM_LENGTH));

    } else if (slotValue.containsSlotValue(ListValue.SLOT_NAME_MAXIMUM_SIZE)
            && slotValue instanceof ListValue) {
        maximumSizeAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MAXIMUM_SIZE);
        maximumSizeAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                (int) slotValue.getSlotValue(ListValue.SLOT_NAME_MAXIMUM_SIZE));

    } else if (slotValue.containsSlotValue(NumericValue.SLOT_NAME_MAXIMUM)
            && slotValue instanceof NumericValue) {
        maximumValueAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MAXIMUM_VALUE);
        maximumValueAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                String.valueOf(slotValue.getSlotValue(NumericValue.SLOT_NAME_MAXIMUM)));

        maximumValueAnnotation.setAttributeValue(AnnotationParameterName.exclusive.name(),
                ((NumericValue) slotValue).isExclusiveMaximum());

    }

    // Minimum values

    if (slotValue.containsSlotValue(TextValue.SLOT_NAME_MINIMUM_LENGTH) && slotValue instanceof TextValue) {
        minimumLengthAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MINIMUM_LENGTH);
        minimumLengthAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                (int) slotValue.getSlotValue(TextValue.SLOT_NAME_MINIMUM_LENGTH));

    } else if (slotValue.containsSlotValue(ListValue.SLOT_NAME_MINIMUM_SIZE)
            && slotValue instanceof ListValue) {
        minimumSizeAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MINIMUM_SIZE);
        minimumSizeAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                (int) slotValue.getSlotValue(ListValue.SLOT_NAME_MINIMUM_SIZE));

    } else if (slotValue.containsSlotValue(NumericValue.SLOT_NAME_MINIMUM)
            && slotValue instanceof NumericValue) {
        minimumValueAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_MINIMUM_VALUE);
        minimumValueAnnotation.setAttributeValue(AnnotationParameterName.value.name(),
                String.valueOf(slotValue.getSlotValue(NumericValue.SLOT_NAME_MINIMUM)));

        minimumValueAnnotation.setAttributeValue(AnnotationParameterName.exclusive.name(),
                ((NumericValue) slotValue).isExclusiveMinimum());

    }

    if (slotValue instanceof CollectionValue) {

        final CollectionValue collectionValue = (CollectionValue) slotValue;
        final Slot elementSlot = collectionValue.getElementSlot();

        if (elementSlot == null) {
            throw new SchemaGeneratorException("The collection value: " + collectionValue
                    + " does not define an element slot. Collection values must have an element type of "
                    + ModelValue.class, null, this);
        }

        final Value elementValue = collectionValue.getElementSlot().getValue();
        if (!(elementValue instanceof ModelValue)) {
            throw new SchemaGeneratorException("The collection value: " + collectionValue
                    + " does not define a model-based element slot. Collection values must have an element type of "
                    + ModelValue.class, null, this);
        }

        collectionSlotAnnotation = new JavaBytecodeAnnotation(
                SchemaGenerator.ANNOTATION_INTERNAL_NAME_COLLECTION_SLOT);

        final URI linkRelationUri = collectionValue.getLinkRelationUri();
        collectionSlotAnnotation.setAttributeValue(AnnotationParameterName.linkRelationUri.name(),
                linkRelationUri.toString());

        final Integer limit = collectionValue.getLimit();
        if (limit != null) {
            if (limit < 1) {
                throw new SchemaGeneratorException(
                        "The collection value: " + collectionValue + " defines an invalid limit: " + limit,
                        null, this);
            }

            collectionSlotAnnotation.setAttributeValue(AnnotationParameterName.limit.name(), limit.toString());
        }

        final List<CollectionValueSearchCriterion> andedCriterionList = collectionValue.getAnd();
        if (andedCriterionList.size() > 0) {
            final JavaBytecodeAnnotation[] andCriterionArray = generateCollectionSlotCriterionArray(
                    andedCriterionList);
            collectionSlotAnnotation.setAttributeValue(AnnotationParameterName.and.name(), andCriterionArray);
        }

        final List<CollectionValueSearchCriterion> oredCriterionList = collectionValue.getOr();
        if (oredCriterionList.size() > 0) {
            final JavaBytecodeAnnotation[] orCriterionArray = generateCollectionSlotCriterionArray(
                    oredCriterionList);
            collectionSlotAnnotation.setAttributeValue(AnnotationParameterName.or.name(), orCriterionArray);
        }

    }

    //
    // Create an object to describe the *read* access method (aka
    // "getter" method) that needs
    // to be generated.
    //
    final JavaBytecodeMethod readMethod = generateMethod(readMethodName, type, aliasAnnotation,
            descriptionAnnotation, titleAnnotation, defaultValueAnnotation, disallowedValuesAnnotation,
            divisibleByAnnotation, maximumValueAnnotation, minimumValueAnnotation, maximumLengthAnnotation,
            minimumLengthAnnotation, maximumSizeAnnotation, minimumSizeAnnotation, multilineAnnotation,
            collectionSlotAnnotation);

    javaBytecodeClass.getMethods().add(readMethod);

    if (aliases != null && aliases.size() > 0) {
        for (final String alias : aliases) {
            if (alias == null) {
                continue;
            }

            final String aliasMethodNameSuffix = StringUtils.capitalize(StringUtils.deleteWhitespace(alias));
            final String aliasReadMethodName = readMethodNamePrefix + aliasMethodNameSuffix;

            final JavaBytecodeMethod aliasReadMethod = generateMethod(aliasReadMethodName, type);

            javaBytecodeClass.getMethods().add(aliasReadMethod);

        }
    }

    if (slotValue instanceof MaybeReadOnly) {

        final Boolean maybeReadOnly = ((MaybeReadOnly) slotValue).isReadOnly();

        if (maybeReadOnly == null || !maybeReadOnly) {

            final String writeMethodName = JavaBean.SET + methodNameSuffix;

            JavaBytecodeAnnotation nonNullAnnotation = null; // ;-)
            if (slotValue instanceof MaybeRequired) {
                final Boolean maybeRequired = ((MaybeRequired) slotValue).isRequired();
                final boolean required = (maybeRequired != null && maybeRequired);
                if (required && !(slotValue instanceof NumericValue) && !(slotValue instanceof BooleanValue)) {
                    nonNullAnnotation = new JavaBytecodeAnnotation(
                            SchemaGenerator.ANNOTATION_INTERNAL_NAME_NON_NULL);
                }
            }

            //
            // Create an object to describe the *write* access method
            // (aka "setter" method) that needs
            // to be generated.
            //
            final JavaBytecodeMethod writeMethod = generateMethod(writeMethodName, type, type,
                    nonNullAnnotation);
            javaBytecodeClass.getMethods().add(writeMethod);

            if (aliases != null && aliases.size() > 0) {
                for (final String alias : aliases) {
                    if (alias == null) {
                        continue;
                    }

                    final String aliasMethodNameSuffix = StringUtils
                            .capitalize(StringUtils.deleteWhitespace(alias));
                    final String aliasWriteMethodName = JavaBean.SET + aliasMethodNameSuffix;
                    final JavaBytecodeMethod aliasWriteMethod = generateMethod(aliasWriteMethodName, type,
                            type);
                    javaBytecodeClass.getMethods().add(aliasWriteMethod);
                }
            }
        }
    }

}

From source file:org.wrml.runtime.schema.generator.SchemaGenerator.java

/**
 * Generates the method associated with a Link slot value ({@link LinkValue}).
 *
 * @param javaBytecodeClass The {@link JavaBytecodeClass} representing the Schema interface being generated.
 * @param isAggregate       <code>true</code> if the {@link Schema} that owns the link {@link Slot} is an {@link org.wrml.model.rest.AggregateDocument}.
 * @param slot              The slot holding the LinkValue to use as a template for a set of generated Java methods.
 *//*  w w  w  . j av  a  2s .  c  o m*/
private void generateLinkMethod(final JavaBytecodeClass javaBytecodeClass, final boolean isAggregate,
        final Slot slot) {

    JavaBytecodeAnnotation aliasAnnotation = null;

    final List<String> aliases = slot.getAliases();
    if (aliases != null && aliases.size() > 0) {
        aliasAnnotation = new JavaBytecodeAnnotation(SchemaGenerator.ANNOTATION_INTERNAL_NAME_ALIASES);
        final String[] aliasesArray = new String[aliases.size()];
        aliasAnnotation.setAttributeValue(AnnotationParameterName.value.name(), aliases.toArray(aliasesArray));
    }

    final JavaBytecodeAnnotation linkSlotAnnotation = new JavaBytecodeAnnotation(
            SchemaGenerator.ANNOTATION_INTERNAL_NAME_LINK_SLOT);

    final LinkValue linkValue = (LinkValue) slot.getValue();

    final URI linkRelationUri = linkValue.getLinkRelationUri();
    if (linkRelationUri == null) {
        throw new SchemaGeneratorException("The link must specify a URI value in its \"linkRelationUri\" slot.",
                null, this);
    }

    final String linkRelationUriString = linkRelationUri.toASCIIString();
    if (linkRelationUriString == null || linkRelationUriString.isEmpty()) {
        throw new SchemaGeneratorException("The link must specify a URI value in its \"linkRelationUri\" slot.",
                null, this);
    }

    linkSlotAnnotation.setAttributeValue(AnnotationParameterName.linkRelationUri.name(), linkRelationUriString);

    final ApiLoader apiLoader = getContext().getApiLoader();
    final LinkRelation linkRelation = apiLoader.loadLinkRelation(linkRelationUri);
    if (linkRelation == null) {
        throw new SchemaGeneratorException("Could not get the LinkRelation with URI: " + linkRelationUri, null,
                this);
    }

    final String slotName = slot.getName();

    final String linkSlotName = StringUtils.deleteWhitespace(slotName);
    String linkMethodName = linkSlotName;

    final Method method = linkRelation.getMethod();
    linkSlotAnnotation.setAttributeValue(AnnotationParameterName.method.name(), method);

    final URI linkValueResponseSchemaUri = linkValue.getResponseSchemaUri();
    final URI linkRelationResponseSchemaUri = linkRelation.getResponseSchemaUri();
    final URI methodReturnSchemaUri = (linkValueResponseSchemaUri != null) ? linkValueResponseSchemaUri
            : linkRelationResponseSchemaUri;
    final JavaBytecodeType methodReturnType = javaBytecodeTypeForSchemaUri(methodReturnSchemaUri);

    final URI linkValueRequestSchemaUri = linkValue.getRequestSchemaUri();
    final URI linkRelationRequestSchemaUri = linkRelation.getRequestSchemaUri();
    final URI methodParameterSchemaUri = (linkValueRequestSchemaUri != null) ? linkValueRequestSchemaUri
            : linkRelationRequestSchemaUri;

    final JavaBytecodeMethod linkMethod;
    if (methodParameterSchemaUri != null) {
        // Link method accepts a parameter
        final JavaBytecodeType methodParameterType = javaBytecodeTypeForSchemaUri(methodParameterSchemaUri);
        linkMethod = generateMethod(linkMethodName, methodReturnType, methodParameterType, aliasAnnotation,
                linkSlotAnnotation);
    } else {
        // A zero argument link method
        if (method == Method.Get) {
            // Links with GET semantics are named with a pattern: get{LinkSlotName}()
            linkMethodName = JavaBean.GET + StringUtils.capitalize(linkMethodName);
        }

        linkMethod = generateMethod(linkMethodName, methodReturnType, aliasAnnotation, linkSlotAnnotation);
    }

    boolean embedded = (linkValue.isEmbedded() || isAggregate) && (method == Method.Get);
    linkSlotAnnotation.setAttributeValue(AnnotationParameterName.embedded.name(), embedded);

    List<LinkValueBinding> linkValueBindings = linkValue.getBindings();
    if (!linkValueBindings.isEmpty()) {

        final JavaBytecodeAnnotation[] bindingsArray = new JavaBytecodeAnnotation[linkValueBindings.size()];
        for (int i = 0; i < bindingsArray.length; i++) {

            final LinkValueBinding linkValueBinding = linkValueBindings.get(i);
            final String referenceSlot = linkValueBinding.getReferenceSlot();
            final String linkValueSource = linkValueBinding.getValueSource();
            final ValueSourceType linkValueSourceType = linkValueBinding.getValueSourceType();

            final JavaBytecodeAnnotation linkSlotBindingAnnotation = new JavaBytecodeAnnotation(
                    SchemaGenerator.ANNOTATION_INTERNAL_NAME_LINK_SLOT_BINDING);
            linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.referenceSlot.name(),
                    referenceSlot);
            linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.valueSource.name(),
                    linkValueSource);
            linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.valueSourceType.name(),
                    linkValueSourceType);

            bindingsArray[i] = linkSlotBindingAnnotation;
        }

        linkSlotAnnotation.setAttributeValue(AnnotationParameterName.bindings.name(), bindingsArray);

    }

    javaBytecodeClass.getMethods().add(linkMethod);

}