class PceccSrTeBeHandler {

    public boolean allocateAdjacencyLabel(Link link) {
        long applyNum = 1; // Single label to each link.
        DeviceId srcDeviceId = link.src().deviceId();
        Collection<LabelResource> labelList;

        checkNotNull(link, LINK_NULL);
        checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
        checkNotNull(pceStore, PCE_STORE_NULL);

        // Checks whether adjacency label was already allocated
        LabelResourceId labelId = pceStore.getAdjLabel(link);
        if (labelId != null) {
            log.debug("Adjacency label {} was already allocated for a link {}.", labelId.toString(), link.toString());
            return false;
        }

        // Allocate adjacency label to a link from label manager.
        // Take label from source device pool to allocate.
        labelList = labelRsrcService.applyFromDevicePool(srcDeviceId, applyNum);
        if (labelList.size() <= 0) {
            log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
            return false;
        }

        // Currently only one label to a device. So, no need to iterate through list
        Iterator<LabelResource> iterator = labelList.iterator();
        DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
        labelId = defaultLabelResource.labelResourceId();
        if (labelId == null) {
            log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
            return false;
        }
        log.debug("Allocated adjacency label {} to a link {}.", labelId.toString(), link.toString());

        // Push adjacency label to device
        installAdjLabelRule(srcDeviceId, labelId, link.src().port(), link.dst().port(), Objective.Operation.ADD);

        // Save in store
        pceStore.addAdjLabel(link, labelId);
        return true;
    }

    private  PceccSrTeBeHandler();

}