public AllocateIdOutputBuilder setIdValue(final java.lang.Long value) { if (value != null) { checkIdValueRange(value); } this._idValue = value; return this; }
public AllocateIdOutputBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
@Override public Future<RpcResult<AllocateIdOutput>> allocateId(AllocateIdInput input) { if (LOG.isDebugEnabled()) { LOG.debug("AllocateId called with input {}", input); } String idKey = input.getIdKey(); String poolName = input.getPoolName(); String localPoolName = IdUtils.getLocalPoolName(poolName); RpcResultBuilder<AllocateIdOutput> allocateIdRpcBuilder; long newIdValue = -1; AllocateIdOutputBuilder output = new AllocateIdOutputBuilder(); try { //allocateIdFromLocalPool method returns a list of IDs with one element. This element is obtatined by get(0) newIdValue = allocateIdFromLocalPool(poolName, localPoolName, idKey, 1).get(0); output.setIdValue(newIdValue); allocateIdRpcBuilder = RpcResultBuilder.success(); allocateIdRpcBuilder.withResult(output.build()); } catch (Exception ex) { LOG.error("Allocate id in pool {} failed due to {}", poolName, ex); allocateIdRpcBuilder = RpcResultBuilder.failed(); allocateIdRpcBuilder.withError(ErrorType.APPLICATION, ex.getMessage()); } return Futures.immediateFuture(allocateIdRpcBuilder.build()); }
private AllocateIdOutputImpl(AllocateIdOutputBuilder base) { this._idValue = base.getIdValue(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }