Example usage for javax.persistence Parameter equals

List of usage examples for javax.persistence Parameter equals

Introduction

In this page you can find the example usage for javax.persistence Parameter equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.impetus.kundera.query.KunderaQuery.java

/**
 * Returns specific clause value.//ww w.j a  v  a 2 s  . co m
 * 
 * @param param
 *            parameter
 * 
 * @return clause value.
 */
public List<Object> getClauseValue(Parameter param) {
    Parameter match = null;
    if (typedParameter != null && typedParameter.jpaParameters != null) {
        for (Parameter p : typedParameter.jpaParameters) {
            if (p.equals(param)) {
                match = p;
                if (typedParameter.getType().equals(Type.NAMED)) {
                    List<FilterClause> clauses = typedParameter.getParameters().get(":" + p.getName());
                    if (clauses != null) {
                        return clauses.get(0).getValue();
                    }
                } else {
                    List<FilterClause> clauses = typedParameter.getParameters().get("?" + p.getPosition());
                    if (clauses != null) {
                        return clauses.get(0).getValue();
                    } else {
                        UpdateClause updateClause = typedParameter.getUpdateParameters()
                                .get("?" + p.getPosition());
                        if (updateClause != null) {
                            List<Object> value = new ArrayList<Object>();
                            value.add(updateClause.getValue());
                            return value;
                        }

                    }
                }
                break;
            }
        }
        if (match == null) {
            throw new IllegalArgumentException("parameter is not a parameter of the query");
        }
    }

    logger.error("parameter{} is not a parameter of the query", param);
    throw new IllegalArgumentException("parameter is not a parameter of the query");
}

From source file:org.squashtest.tm.domain.testcase.TestCase.java

/**
 * If the given parameter doesn't already exists in this.parameters, and, if the given parameter's name is not found
 * in this.parmeters : will add the given parameter to this.parameters.
 *
 * @throws NameAlreadyInUseException/*  ww  w. j  a v a 2  s. c  o  m*/
 * @param parameter
 */
protected void addParameter(@NotNull Parameter parameter) {
    Parameter homonyme = findParameterByName(parameter.getName());
    if (homonyme != null && !homonyme.equals(parameter)) {
        throw new NameAlreadyInUseException(Parameter.class.getSimpleName(), parameter.getName());
    }
    this.parameters.add(parameter);

}