Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Checking for null method inputs - using checkNotNull(): 

    Code Block
    languagejava
    import static com.google.common.base.Preconditions.checkNotNull;
    ...
        @Override
        public void removeDevice(DeviceId deviceId) {
            checkNotNull(deviceId, DEVICE_ID_NULL);
            DeviceEvent event = store.removeDevice(deviceId);
            if (event != null) {
                log.info("Device {} administratively removed", deviceId);
                post(event);
            }
        }
  • toString()ToStringHelper():

    Code Block
    languagejava
    import static com.google.common.base.MoreObjects.toStringHelper;
    ...
        @Override
        public String toString() {
            return toStringHelper(this)
                    .add("id", id)
                    .add("vlan", vlan)
                    .add("ipAddresses", ips)
                    .toString();
        }
  • Data structures such as Lists, ImmutableSet, and HashMultiMap
  • Unit testing - EqualsTester():

    Code Block
    languagejava
    import com.google.common.testing.EqualsTester;
    ...
    VlanId vlan1 = VlanId.vlanId((short) -1);
    VlanId vlan2 = VlanId.vlanId((short) 100);
    VlanId vlan3 = VlanId.vlanId((short) 100);
     
    // first two equality groups contain equal objects, last differs
    // from constituents of first two groups
    new EqualsTester().addEqualityGroup(VlanId.vlanId(), vlan1)
            .addEqualityGroup(vlan2, vlan3)
            .addEqualityGroup(VlanId.vlanId((short) 10));


 

...

Home : Contributing to the ONOS Codebase

...