public void setLastSeenTimestamp(Date lastSeenTimestamp) {
if (activeSince == null
|| (activeSince.getTime() + ACTIVITY_TIMEOUT) < lastSeenTimestamp
- .getTime())
+ .getTime()) {
this.activeSince = lastSeenTimestamp;
+ }
this.lastSeenTimestamp = lastSeenTimestamp;
}
@Override
public int hashCode() {
- if (hashCode != 0)
+ if (hashCode != 0) {
return hashCode;
+ }
final int prime = 31;
hashCode = 1;
hashCode = prime * hashCode
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Entity other = (Entity) obj;
if (ipv4Address == null) {
- if (other.ipv4Address != null)
+ if (other.ipv4Address != null) {
return false;
- } else if (!ipv4Address.equals(other.ipv4Address))
+ }
+ } else if (!ipv4Address.equals(other.ipv4Address)) {
return false;
- if (macAddress != other.macAddress)
+ }
+ if (macAddress != other.macAddress) {
return false;
+ }
if (port == null) {
- if (other.port != null)
+ if (other.port != null) {
return false;
- } else if (!port.equals(other.port))
+ }
+ } else if (!port.equals(other.port)) {
return false;
+ }
if (vlan == null) {
- if (other.vlan != null)
+ if (other.vlan != null) {
return false;
- } else if (!vlan.equals(other.vlan))
+ }
+ } else if (!vlan.equals(other.vlan)) {
return false;
+ }
return true;
}
Comparable switchId = (Comparable) port.getNode().getID();
Comparable oswitchId = (Comparable) o.port.getNode().getID();
r = switchId.compareTo(oswitchId);
- if (r != 0)
+ if (r != 0) {
return r;
+ }
Comparable portId = (Comparable) port.getID();
Comparable oportId = (Comparable) o.port.getID();
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
SwitchPort other = (SwitchPort) obj;
- if (errorStatus != other.errorStatus)
+ if (errorStatus != other.errorStatus) {
return false;
+ }
if (port == null) {
- if (other.port != null)
+ if (other.port != null) {
return false;
- } else if (!port.equals(other.port))
+ }
+ } else if (!port.equals(other.port)) {
return false;
+ }
return true;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
HostNodeConnector other = (HostNodeConnector) obj;
if (nodeConnector == null) {
- if (other.nodeConnector != null)
+ if (other.nodeConnector != null) {
return false;
- } else if (!nodeConnector.equals(other.nodeConnector))
+ }
+ } else if (!nodeConnector.equals(other.nodeConnector)) {
return false;
- if (staticHost != other.staticHost)
+ }
+ if (staticHost != other.staticHost) {
return false;
- if (vlan != other.vlan)
+ }
+ if (vlan != other.vlan) {
return false;
+ }
return true;
}
EthernetAddress e = (EthernetAddress) getDataLayerAddress();
macaddr = e.getValue();
}
- if (macaddr == null)
+ if (macaddr == null) {
return false;
+ }
return !Arrays.equals(emptyArray, macaddr);
}
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);
+ }
}
}
return objects;
@Override
public synchronized void explore() {
- if (_explored) return;
+ if (_explored) {
+ return;
+ }
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 {
- if (queryString == null || queryString.trim().length() == 0) return null;
+ if (queryString == null || queryString.trim().length() == 0) {
+ return null;
+ }
try {
- 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);
- 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) {
- if (LOGGER.isDebugEnabled()) LOGGER.error("Query processing failed = {}",
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.error("Query processing failed = {}",
queryString, ex);
+ }
throw new QueryException("Unable to parse query.", ex);
}
}
}
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();
}
}
private Object parse(String arg, Object value) {
- if (value == null) return null;
+ if (value == null) {
+ return null;
+ }
try {
if (value instanceof String) {
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())) {
}
}
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
* Explore the type info for children.
*/
public synchronized void explore() {
- if (_explored) return;
+ if (_explored) {
+ return;
+ }
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) {
- if (LOGGER.isDebugEnabled()) LOGGER.debug(
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(
"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) {
- if (LOGGER.isDebugEnabled()) LOGGER.debug(
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(
"exploring type: {} name: {} field: {}",
_class.getSimpleName(), tn, f);
+ }
_types.put(tn, createTypeInfo(tn, new Accessor(f)));
}
}
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)
// 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);
}
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();
return null;
}
}
- if (DEFAULT_NAME.equals(name)) return dflt;
+ if (DEFAULT_NAME.equals(name)) {
+ return dflt;
+ }
return name;
}
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]);
- 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
@Override
public synchronized void explore() {
- if (_explored) return;
+ if (_explored) {
+ return;
+ }
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("exploring wrapper type: {} gtype: {}", _class,
_accessor.getGenericType());
public static void checkCondition(boolean condition, String message,
JmxAttribute jmxAttribute) throws JmxAttributeValidationException {
- if (condition == false) {
+ if (!condition) {
throw new JmxAttributeValidationException(
jmxAttribute.getAttributeName() + " " + message,
jmxAttribute);
if (quoted == null) {
throw new IllegalArgumentException("Cannot find " + SERVICE_QNAME_KEY + " in " + objectName);
}
- if (quoted.startsWith("\"") == false || quoted.endsWith("\"") == false) {
+ if (!quoted.startsWith("\"") || !quoted.endsWith("\"")) {
throw new IllegalArgumentException("Quotes not found in " + objectName);
}
String substring = quoted.substring(1);
throw new IllegalArgumentException(
"Expected ObjectName with transaction:" + inputON);
}
- if (ON_DOMAIN.equals(inputON.getDomain()) == false) {
+ if (!ON_DOMAIN.equals(inputON.getDomain())) {
throw new IllegalArgumentException("Expected different domain: "
+ inputON);
}
Map<String, String> allProperties = getAdditionalProperties(on);
Map<String, String> result = new HashMap<>();
for (Entry<String, String> entry : allProperties.entrySet()) {
- if (blacklist.contains(entry.getKey()) == false) {
+ if (!blacklist.contains(entry.getKey())) {
result.put(entry.getKey(), entry.getValue());
}
}
package org.opendaylight.controller.sal.binding.impl;
import static com.google.common.base.Preconditions.checkState;
-
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.EventListener;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
-
import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Throwables;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.util.concurrent.UncheckedExecutionException;
-
public class RpcProviderRegistryImpl implements RpcProviderRegistry, RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
private RuntimeCodeGenerator rpcFactory = SingletonHolder.RPC_GENERATOR_IMPL;
}
- private class RouteChangeForwarder<T extends RpcService> implements RouteChangeListener<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
-
+ private final class RouteChangeForwarder<T extends RpcService> implements RouteChangeListener<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
private final Class<T> type;
- public RouteChangeForwarder(final Class<T> type) {
+ RouteChangeForwarder(final Class<T> type) {
this.type = type;
}
}
}
- public static class RpcProxyRegistration<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
-
+ private static final class RpcProxyRegistration<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
+ private final RpcProviderRegistryImpl registry;
private final Class<T> serviceType;
- private RpcProviderRegistryImpl registry;
- public RpcProxyRegistration(final Class<T> type, final T service, final RpcProviderRegistryImpl registry) {
+ RpcProxyRegistration(final Class<T> type, final T service, final RpcProviderRegistryImpl registry) {
super(service);
+ this.registry = Preconditions.checkNotNull(registry);
this.serviceType = type;
- this.registry = registry;
}
@Override
@Override
protected void removeRegistration() {
- if (registry != null) {
- T publicProxy = registry.getRpcService(serviceType);
- RpcService currentDelegate = RuntimeCodeHelper.getDelegate(publicProxy);
- if (currentDelegate == getInstance()) {
- RuntimeCodeHelper.setDelegate(publicProxy, null);
- }
- registry = null;
+ T publicProxy = registry.getRpcService(serviceType);
+ RpcService currentDelegate = RuntimeCodeHelper.getDelegate(publicProxy);
+ if (currentDelegate == getInstance()) {
+ RuntimeCodeHelper.setDelegate(publicProxy, null);
}
}
}
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
-import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.core.api.RpcImplementation;
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
private final Set<QName> supportedRpcs;
private final WeakReference<Class<? extends RpcService>> rpcServiceType;
- private Set<org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration> registrations;
+ private Set<RoutedRpcRegistration> registrations;
private final Map<QName, RpcInvocationStrategy> strategiesByQName = new HashMap<>();
private final WeakHashMap<Method, RpcInvocationStrategy> strategiesByMethod = new WeakHashMap<>();
private final RpcService proxy;
final RpcProvisionRegistry biRpcRegistry, final RpcProviderRegistry baRpcRegistry, final RpcProviderRegistryImpl registryImpl) {
this(service, mappingService, biRpcRegistry, baRpcRegistry,registryImpl);
- final ImmutableSet.Builder<Broker.RoutedRpcRegistration> registrationsBuilder = ImmutableSet.builder();
+ final ImmutableSet.Builder<RoutedRpcRegistration> registrationsBuilder = ImmutableSet.builder();
try {
for (QName rpc : supportedRpcs) {
registrationsBuilder.add(biRpcRegistry.addRoutedRpcImplementation(rpc, this));
public void registerPaths(final Class<? extends BaseIdentity> context,
final Class<? extends RpcService> service, final Set<InstanceIdentifier<?>> set) {
QName ctx = BindingReflections.findQName(context);
- for (YangInstanceIdentifier path : FluentIterable.from(set).transform(
- toDOMInstanceIdentifier)) {
- for (org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration reg : registrations) {
+ for (YangInstanceIdentifier path : Collections2.transform(set, toDOMInstanceIdentifier)) {
+ for (RoutedRpcRegistration reg : registrations) {
reg.registerPath(ctx, path);
}
}
public void removePaths(final Class<? extends BaseIdentity> context, final Class<? extends RpcService> service,
final Set<InstanceIdentifier<?>> set) {
QName ctx = BindingReflections.findQName(context);
- for (YangInstanceIdentifier path : FluentIterable.from(set).transform(
- toDOMInstanceIdentifier)) {
- for (org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration reg : registrations) {
+ for (YangInstanceIdentifier path : Collections2.transform(set, toDOMInstanceIdentifier)) {
+ for (RoutedRpcRegistration reg : registrations) {
reg.unregisterPath(ctx, path);
}
}