Change-Id: Iadad636ebf07e8c31a8c85540f10180b825c8a4a
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Object item = it.next();
for (TypeInfo child : _types.values()) {
Object val = child.retrieve(item, query, index);
Object item = it.next();
for (TypeInfo child : _types.values()) {
Object val = child.retrieve(item, query, index);
- if (val != null) objects.add(val);
+ if (val != null) {
+ objects.add(val);
+ }
@Override
public synchronized void explore() {
@Override
public synchronized void explore() {
+ if (_explored) {
+ return;
+ }
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("exploring iteratable type: {} gtype: {}", _class,
_accessor.getGenericType());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("exploring iteratable type: {} gtype: {}", _class,
_accessor.getGenericType());
@Override
public <T> Query<T> createQuery(String queryString, Class<T> type) throws QueryException {
@Override
public <T> Query<T> createQuery(String queryString, Class<T> type) throws QueryException {
- if (queryString == null || queryString.trim().length() == 0) return null;
+ if (queryString == null || queryString.trim().length() == 0) {
+ return null;
+ }
- if (LOGGER.isDebugEnabled()) LOGGER.debug("Processing query: {}", queryString);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Processing query: {}", queryString);
+ }
// FiqlParser is a parser generated by javacc
Expression expression = FiqlParser.parse(queryString);
// FiqlParser is a parser generated by javacc
Expression expression = FiqlParser.parse(queryString);
- if (LOGGER.isDebugEnabled()) LOGGER.debug("Query expression: {}", expression);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Query expression: {}", expression);
+ }
// create Query and return;
return new QueryImpl<T>(type, expression);
} catch (Exception ex) {
// create Query and return;
return new QueryImpl<T>(type, expression);
} catch (Exception ex) {
- if (LOGGER.isDebugEnabled()) LOGGER.error("Query processing failed = {}",
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.error("Query processing failed = {}",
throw new QueryException("Unable to parse query.", ex);
}
}
throw new QueryException("Unable to parse query.", ex);
}
}
}
private boolean compare(Object valueToMatch, Object actualValue, OP operator) {
}
private boolean compare(Object valueToMatch, Object actualValue, OP operator) {
- if (valueToMatch == null || actualValue == null) return false;
+ if (valueToMatch == null || actualValue == null) {
+ return false;
+ }
if (ALLOW_OBJECT_STRING_COMPARE && (valueToMatch instanceof String)
&& !(actualValue instanceof String)) {
actualValue = actualValue.toString();
if (ALLOW_OBJECT_STRING_COMPARE && (valueToMatch instanceof String)
&& !(actualValue instanceof String)) {
actualValue = actualValue.toString();
}
}
private Object parse(String arg, Object value) {
}
}
private Object parse(String arg, Object value) {
- if (value == null) return null;
+ if (value == null) {
+ return null;
+ }
try {
if (value instanceof String) {
try {
if (value instanceof String) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("retrieve: {}/{} type:{}", index, query.length, target.getClass());
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("retrieve: {}/{} type:{}", index, query.length, target.getClass());
}
- if (index >= query.length) return null;
+ if (index >= query.length) {
+ return null;
+ }
explore();
if (!target.getClass().equals(_class)) {
if (_class.isAssignableFrom(target.getClass())) {
explore();
if (!target.getClass().equals(_class)) {
if (_class.isAssignableFrom(target.getClass())) {
}
}
TypeInfo child = getChild(query[index]);
}
}
TypeInfo child = getChild(query[index]);
- if (child == null) return null;
+ if (child == null) {
+ return null;
+ }
target = child.getAccessor().getValue(target);
if (index+1 == query.length) {
// match found
target = child.getAccessor().getValue(target);
if (index+1 == query.length) {
// match found
* Explore the type info for children.
*/
public synchronized void explore() {
* Explore the type info for children.
*/
public synchronized void explore() {
+ if (_explored) {
+ return;
+ }
for (Class<?> c = _class; c != null; c = c.getSuperclass()) {
for (Class<?> c = _class; c != null; c = c.getSuperclass()) {
- if (c.equals(Object.class)) break;
+ if (c.equals(Object.class)) {
+ break;
+ }
// Currently only fields and methods annotated with JAXB annotations are
// considered as valid for search purposes.
//check methods first
for (Method m : c.getDeclaredMethods()) {
String tn = getTypeName(m, _accessType);
if (tn != null) {
// Currently only fields and methods annotated with JAXB annotations are
// considered as valid for search purposes.
//check methods first
for (Method m : c.getDeclaredMethods()) {
String tn = getTypeName(m, _accessType);
if (tn != null) {
- if (LOGGER.isDebugEnabled()) LOGGER.debug(
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(
"exploring type: {} name: {} method: {}",
_class.getSimpleName(), tn, m);
"exploring type: {} name: {} method: {}",
_class.getSimpleName(), tn, m);
_types.put(tn, createTypeInfo(tn, new Accessor(m)));
}
}
for (Field f : c.getDeclaredFields()) {
String tn = getTypeName(f, _accessType);
if (tn != null) {
_types.put(tn, createTypeInfo(tn, new Accessor(m)));
}
}
for (Field f : c.getDeclaredFields()) {
String tn = getTypeName(f, _accessType);
if (tn != null) {
- if (LOGGER.isDebugEnabled()) LOGGER.debug(
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(
"exploring type: {} name: {} field: {}",
_class.getSimpleName(), tn, f);
"exploring type: {} name: {} field: {}",
_class.getSimpleName(), tn, f);
_types.put(tn, createTypeInfo(tn, new Accessor(f)));
}
}
_types.put(tn, createTypeInfo(tn, new Accessor(f)));
}
}
PropertyDescriptor[] props = info.getPropertyDescriptors();
for (PropertyDescriptor pd : props)
{
PropertyDescriptor[] props = info.getPropertyDescriptors();
for (PropertyDescriptor pd : props)
{
- if (m.equals(pd.getReadMethod())) return pd.getName();
+ if (m.equals(pd.getReadMethod())) {
+ return pd.getName();
+ }
}
}
catch (IntrospectionException e)
}
}
catch (IntrospectionException e)
// root is always a composite type
// FIXME assert its a JAXB type
XmlRootElement root = clz.getAnnotation(XmlRootElement.class);
// root is always a composite type
// FIXME assert its a JAXB type
XmlRootElement root = clz.getAnnotation(XmlRootElement.class);
- if (root == null) throw new IllegalArgumentException("Not a JAXB type: " + clz);
- if (name == null) name = getRootName(clz);
+ if (root == null) {
+ throw new IllegalArgumentException("Not a JAXB type: " + clz);
+ }
+ if (name == null) {
+ name = getRootName(clz);
+ }
return new TypeInfo(name, clz, null);
}
return new TypeInfo(name, clz, null);
}
public static String getRootName(Class<?> cls) {
XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
public static String getRootName(Class<?> cls) {
XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
- if (root == null) return null;
+ if (root == null) {
+ return null;
+ }
String rootName = root.name();
if (DEFAULT_NAME.equals(rootName)) {
String clsName = cls.getSimpleName();
String rootName = root.name();
if (DEFAULT_NAME.equals(rootName)) {
String clsName = cls.getSimpleName();
- if (DEFAULT_NAME.equals(name)) return dflt;
+ if (DEFAULT_NAME.equals(name)) {
+ return dflt;
+ }
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("retrieve collection: {}/{}", index, query.length);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("retrieve collection: {}/{}", index, query.length);
}
- if (index >= query.length) return null;
+ if (index >= query.length) {
+ return null;
+ }
explore();
TypeInfo child = getChild(query[index]);
explore();
TypeInfo child = getChild(query[index]);
- if (child == null) return null;
+ if (child == null) {
+ return null;
+ }
if (query.length == index+1) { // skipping this node
return target;
}else { // if list of list go to next node to get value
if (query.length == index+1) { // skipping this node
return target;
}else { // if list of list go to next node to get value
@Override
public synchronized void explore() {
@Override
public synchronized void explore() {
+ if (_explored) {
+ return;
+ }
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("exploring wrapper type: {} gtype: {}", _class,
_accessor.getGenericType());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("exploring wrapper type: {} gtype: {}", _class,
_accessor.getGenericType());