/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public PartialUpdateInstanceRequest toProto(String projectId) { // Empty field mask implies full resource replacement, which would clear all fields in an empty // update request. Preconditions.checkState( !builder.getUpdateMask().getPathsList().isEmpty(), "Update request is empty"); builder.getInstanceBuilder().setName(NameUtil.formatInstanceName(projectId, instanceId)); return builder.build(); } }
public static boolean isAbiMissing(DeviceSpec deviceSpec) { return deviceSpec.getSupportedAbisList().isEmpty(); }
public static boolean isLocalesMissing(DeviceSpec deviceSpec) { return deviceSpec.getSupportedLocalesList().isEmpty(); }
public static Optional<String> getLocaleName(LanguageTargeting languageTargeting) { if (languageTargeting.getValueList().isEmpty()) { return Optional.empty(); } return Optional.of(Iterables.getOnlyElement(languageTargeting.getValueList())); }
@Override protected boolean isDeviceDimensionPresent() { return !getDeviceSpec().getSupportedAbisList().isEmpty(); }
@Override protected boolean isDeviceDimensionPresent() { return !getDeviceSpec().getSupportedAbisList().isEmpty(); } }
@Override protected boolean isDeviceDimensionPresent() { return !getDeviceSpec().getDeviceFeaturesList().isEmpty(); }
private static void validateDeviceSpec(DeviceSpec deviceSpec, boolean canSkipFields) { if (deviceSpec.getSdkVersion() < 0 || (!canSkipFields && deviceSpec.getSdkVersion() == 0)) { throw ValidationException.builder() .withMessage( "Device spec SDK version (%d) should be set to a strictly positive number.", deviceSpec.getSdkVersion()) .build(); } if (deviceSpec.getScreenDensity() < 0 || (!canSkipFields && deviceSpec.getScreenDensity() == 0)) { throw ValidationException.builder() .withMessage( "Device spec screen density (%d) should be set to a strictly positive number.", deviceSpec.getScreenDensity()) .build(); } if (!canSkipFields) { if (deviceSpec.getSupportedAbisList().isEmpty()) { throw new ValidationException("Device spec supported ABI list is empty."); } if (deviceSpec.getSupportedLocalesList().isEmpty()) { throw new ValidationException("Device spec supported locales list is empty."); } } }
private Response createResponse(DiscoveryRequest request, Map<String, ? extends Message> resources, String version) { Collection<? extends Message> filtered = request.getResourceNamesList().isEmpty() ? resources.values() : request.getResourceNamesList().stream() .map(resources::get) .filter(Objects::nonNull) .collect(Collectors.toList()); return Response.create(request, filtered, version); }
public RequireUseStrict(AbstractCompiler compiler, Requirement requirement) throws InvalidRequirementSpec { super(compiler, requirement); if (!requirement.getValueList().isEmpty()) { throw new InvalidRequirementSpec("invalid value"); } }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public PartialUpdateInstanceRequest toProto(String projectId) { // Empty field mask implies full resource replacement, which would clear all fields in an empty // update request. Preconditions.checkState( !builder.getUpdateMask().getPathsList().isEmpty(), "Update request is empty"); builder.getInstanceBuilder().setName(NameUtil.formatInstanceName(projectId, instanceId)); return builder.build(); } }
@Override public AgentController newInstance(final UnitConfig agentUnitConfig) throws InstantiationException { AgentController agent; try { if (agentUnitConfig == null) { throw new NotAvailableException("agentconfig"); } if (!agentUnitConfig.getAgentConfig().hasAgentClassId()) { throw new NotAvailableException("agentype"); } if (!agentUnitConfig.hasScope() && agentUnitConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("scope"); } CachedAgentRegistryRemote.waitForData(); final Class agentClass = Thread.currentThread().getContextClassLoader().loadClass(getAgentClass(agentUnitConfig)); logger.debug("Creating agent of type [" + agentClass.getSimpleName() + "] on scope [" + ScopeGenerator.generateStringRep(agentUnitConfig.getScope()) + "]"); agent = (AgentController) agentClass.newInstance(); agent.init(agentUnitConfig); } catch (CouldNotPerformException | ClassNotFoundException | SecurityException | java.lang.InstantiationException | IllegalAccessException | IllegalArgumentException | InterruptedException ex) { throw new InstantiationException(Agent.class, agentUnitConfig.getId(), ex); } return agent; }
@Override public void processData(String id, IdentifiableMessage<String, UnitConfig, Builder> entry, ProtoBufMessageMap<String, UnitConfig, Builder> entryMap, ProtoBufRegistry<String, UnitConfig, Builder> registry) throws CouldNotPerformException, EntryModification { if (entry.getMessage().getAliasList().isEmpty()) { if (updateNeeded) { try { updateUnitTypeAliasNumberMap(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not update internal alias map!", ex, LOGGER); } } UnitConfig.Builder unitConfig = entry.getMessage().toBuilder(); unitConfig.addAlias(generateAndRegisterAlias(unitConfig.getType())); throw new EntryModification(entry.setMessage(unitConfig), this); } }
public static ScopeType.Scope generateConnectionScope(final UnitConfig connectionConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (connectionConfig == null) { throw new NotAvailableException("connectionConfig"); } if (!connectionConfig.hasLabel()) { throw new NotAvailableException("connectionConfig.label"); } if (connectionConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field connectionConfig.label isEmpty"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(connectionConfig.getType().name().replace("_", ""))); // add unit label scope.addComponent(convertIntoValidScopeComponent(connectionConfig.getLabel())); return scope.build(); }
public static ScopeType.Scope generateUnitScope(final UnitConfig unitConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (unitConfig == null) { throw new NotAvailableException("unitConfig"); } if (!unitConfig.hasLabel()) { throw new NotAvailableException("unitConfig.label"); } if (unitConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field unitConfig.label isEmpty"); } if (!unitConfig.hasPlacementConfig()) { throw new NotAvailableException("placement config"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(unitConfig.getType().name().replace("_", ""))); // add unit label scope.addComponent(convertIntoValidScopeComponent(unitConfig.getLabel())); return scope.build(); }
public static ScopeType.Scope generateSceneScope(final UnitConfig sceneUnitConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (sceneUnitConfig == null) { throw new NotAvailableException("sceneConfig"); } if (!sceneUnitConfig.hasLabel()) { throw new NotAvailableException("sceneConfig.label"); } if (sceneUnitConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field sceneConfig.label isEmpty"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(sceneUnitConfig.getType().name())); // add unit label scope.addComponent(convertIntoValidScopeComponent(sceneUnitConfig.getLabel())); return scope.build(); }
if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope");
public static ScopeType.Scope generateDeviceScope(final UnitConfig deviceConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (deviceConfig == null) { throw new NotAvailableException("deviceConfig"); } if (!deviceConfig.hasLabel()) { throw new NotAvailableException("device label"); } if (!deviceConfig.hasPlacementConfig()) { throw new NotAvailableException("placement config"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add type 'device' scope.addComponent(convertIntoValidScopeComponent("device")); // add device scope scope.addComponent(convertIntoValidScopeComponent(deviceConfig.getLabel())); return scope.build(); }
if (!locationUnitConfig.hasScope() || locationUnitConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope");