@Override public BlockFamily getBlockFamily(BlockUri uri) { BlockFamily family = registeredBlockInfo.get().registeredFamilyByUri.get(uri); if (family == null && generateNewIds) { if (isFreeformFamily(uri.getRootFamilyUri())) { family = blockLoader.loadWithShape(uri); } else { family = getAvailableBlockFamily(uri); } if (family != null) { lock.lock(); try { for (Block block : family.getBlocks()) { block.setId(getNextId()); } registerFamily(family); } finally { lock.unlock(); } } else { logger.warn("Unable to resolve block family {}", uri); } } return family; }
@Override public boolean hasBlockFamily(BlockUri uri) { if (registeredBlockInfo.get().registeredFamilyByUri.containsKey(uri) || availableFamilies.containsKey(uri) || freeformBlockUris.contains(uri)) { return true; } return uri.hasShape() && Assets.get(uri.getShapeUri()) != null && freeformBlockUris.contains(uri.getRootFamilyUri()); }
@Override public boolean isFreeformFamily(BlockUri familyUri) { return freeformBlockUris.contains(familyUri.getRootFamilyUri()); }