/** * Add the given permission to the permission set. * * @param permissions The permission set * @param toAdd The permissions to add * @return The same permission set as passed in */ private static EnumSet<Permission> addPermission( EnumSet<Permission> permissions, Permission... toAdd) { for (Permission onePerm : toAdd) { // Permissions that infer other permissions need to be listed here and // set the inferred permissions as well as itself. // // Always add the permission itself and then call this method to add // the inferred permissions. switch (onePerm) { case ADMIN: permissions.addAll(EnumSet.allOf(Permission.class)); break; case SQL: permissions.add(SQL); addPermission(permissions, SQLREAD, DEFAULTPROC); break; case SQLREAD: permissions.add(SQLREAD); addPermission(permissions, DEFAULTPROCREAD); break; case DEFAULTPROC: permissions.add(DEFAULTPROC); addPermission(permissions, DEFAULTPROCREAD); default: permissions.add(onePerm); } } return permissions; }
private void postViewSwitched(int direction) { if (direction != 0) { if (direction > 0) { mCurrentAdapterIndex++; mCurrentBufferIndex++; mLazyInit.remove(LazyInit.LEFT); mLazyInit.add(LazyInit.RIGHT); if (mCurrentAdapterIndex > mBufferedItemCount) { recycleView(mLoadedViews.removeFirst()); mCurrentBufferIndex--; } int newBufferIndex = mCurrentAdapterIndex + mBufferedItemCount; if (newBufferIndex < mAdapter.getCount()) mLoadedViews.addLast(makeAndAddView(newBufferIndex, true)); } else { mCurrentAdapterIndex--; mCurrentBufferIndex--; mLazyInit.add(LazyInit.LEFT); mLazyInit.remove(LazyInit.RIGHT); if (mAdapter.getCount() - 1 - mCurrentAdapterIndex > mBufferedItemCount) { recycleView(mLoadedViews.removeLast()); } int newBufferIndex = mCurrentAdapterIndex - mBufferedItemCount; if (newBufferIndex > -1) { mLoadedViews.addFirst(makeAndAddView(newBufferIndex, false)); mCurrentBufferIndex++; } } requestLayout(); setVisibleView(mCurrentBufferIndex, true); if (viewSwitchListener != null) { viewSwitchListener.onSwitched(mLoadedViews.get(mCurrentBufferIndex), mCurrentAdapterIndex); } } }
@SuppressWarnings("fallthrough") public RichConfiguration(Options options, AbstractDiagnosticFormatter formatter) { super(formatter.getConfiguration()); features = formatter.isRaw() ? EnumSet.noneOf(RichFormatterFeature.class) : EnumSet.of( RichFormatterFeature.SIMPLE_NAMES, RichFormatterFeature.WHERE_CLAUSES, RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); String diagOpts = options.get("diags"); if (diagOpts != null) { for (String args : diagOpts.split(",")) { if (args.equals("-where")) { features.remove(RichFormatterFeature.WHERE_CLAUSES); } else if (args.equals("where")) { features.add(RichFormatterFeature.WHERE_CLAUSES); } if (args.equals("-simpleNames")) { features.remove(RichFormatterFeature.SIMPLE_NAMES); } else if (args.equals("simpleNames")) { features.add(RichFormatterFeature.SIMPLE_NAMES); } if (args.equals("-disambiguateTvars")) { features.remove(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); } else if (args.equals("disambiguateTvars")) { features.add(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES); } } } }
/** {@inheritDoc} */ @Override public CGraph transform(final LGraph inputGraph) { layeredGraph = inputGraph; // checking if the graph has edges and possibly prohibiting vertical compaction hasEdges = layeredGraph .getLayers() .stream() .flatMap(l -> l.getNodes().stream()) .anyMatch(n -> !Iterables.isEmpty(n.getConnectedEdges())); EnumSet<Direction> supportedDirections = EnumSet.of(Direction.UNDEFINED, Direction.LEFT, Direction.RIGHT); if (!hasEdges) { supportedDirections.add(Direction.UP); supportedDirections.add(Direction.DOWN); } // initializing fields cGraph = new CGraph(supportedDirections); // importing LGraphElements into CNodes readNodes(); return cGraph; }
public static void updateGUITicks(BaseModProxy mod, boolean enable, boolean useClock) { ModLoaderModContainer mlmc = (ModLoaderModContainer) Loader.instance().getReversedModObjectList().get(mod); if (mlmc == null) { mlmc = (ModLoaderModContainer) Loader.instance().activeModContainer(); } if (mlmc == null) { FMLLog.severe("Attempted to register ModLoader ticking for invalid BaseMod %s", mod); return; } EnumSet<TickType> ticks = mlmc.getGUITickHandler().ticks(); // If we're enabled and we don't want clock ticks we get render ticks if (enable && !useClock) { ticks.add(TickType.RENDER); } else { ticks.remove(TickType.RENDER); } // If we're enabled but we want clock ticks, or we're server side we get world ticks if (enable && useClock) { ticks.add(TickType.CLIENT); ticks.add(TickType.WORLDLOAD); } else { ticks.remove(TickType.CLIENT); ticks.remove(TickType.WORLDLOAD); } }
@Override public void loopMainThreadUntilIdle() { initialize(); checkState(Looper.myLooper() == mainLooper, "Expecting to be on main thread!"); do { EnumSet<IdleCondition> condChecks = EnumSet.noneOf(IdleCondition.class); if (!asyncTaskMonitor.isIdleNow()) { asyncTaskMonitor.notifyWhenIdle( new SignalingTask<Void>(NO_OP, IdleCondition.ASYNC_TASKS_HAVE_IDLED, generation)); condChecks.add(IdleCondition.ASYNC_TASKS_HAVE_IDLED); } if (!compatIdle()) { compatTaskMonitor.notifyWhenIdle( new SignalingTask<Void>(NO_OP, IdleCondition.COMPAT_TASKS_HAVE_IDLED, generation)); condChecks.add(IdleCondition.COMPAT_TASKS_HAVE_IDLED); } if (!idlingResourceRegistry.allResourcesAreIdle()) { final IdlingPolicy warning = IdlingPolicies.getDynamicIdlingResourceWarningPolicy(); final IdlingPolicy error = IdlingPolicies.getDynamicIdlingResourceErrorPolicy(); final SignalingTask<Void> idleSignal = new SignalingTask<Void>(NO_OP, IdleCondition.DYNAMIC_TASKS_HAVE_IDLED, generation); idlingResourceRegistry.notifyWhenAllResourcesAreIdle( new IdleNotificationCallback() { @Override public void resourcesStillBusyWarning(List<String> busyResourceNames) { warning.handleTimeout(busyResourceNames, "IdlingResources are still busy!"); } @Override public void resourcesHaveTimedOut(List<String> busyResourceNames) { error.handleTimeout(busyResourceNames, "IdlingResources have timed out!"); controllerHandler.post(idleSignal); } @Override public void allResourcesIdle() { controllerHandler.post(idleSignal); } }); condChecks.add(IdleCondition.DYNAMIC_TASKS_HAVE_IDLED); } try { loopUntil(condChecks); } finally { asyncTaskMonitor.cancelIdleMonitor(); if (null != compatTaskMonitor) { compatTaskMonitor.cancelIdleMonitor(); } idlingResourceRegistry.cancelIdleMonitor(); } } while (!asyncTaskMonitor.isIdleNow() || !compatIdle() || !idlingResourceRegistry.allResourcesAreIdle()); }
/* (non-Javadoc) * @see org.jsoar.util.commands.SoarCommand#execute(java.lang.String[]) */ @Override public String execute(SoarCommandContext commandContext, String[] args) throws SoarException { if (args.length < 2) { throw new SoarException("Expected fileName argument"); } final boolean topLevel = topLevelState == null; final boolean reload = "-r".equals(args[1]) || "--reload".equals(args[1]); if (topLevel && reload && lastTopLevelCommand != null) { return "Reloaded: " + StringTools.join(Arrays.asList(lastTopLevelCommand), " ") + "\n" + execute(commandContext, lastTopLevelCommand); } else if (!topLevel && reload) { throw new SoarException(args[1] + " option only valid at top level"); } else if (lastTopLevelCommand == null && reload) { throw new SoarException("No previous file to reload"); } // Process args to get list of files and options ... final List<String> files = new ArrayList<String>(); final EnumSet<Options> opts = EnumSet.noneOf(Options.class); for (int i = 1; i < args.length; ++i) { final String arg = args[i]; if (arg.equals("-d") || arg.equals("--disable")) opts.add(Options.DISABLE); else if (arg.equals("-a") || arg.equals("--all")) opts.add(Options.ALL); else if (arg.equals("-v") || arg.endsWith("--verbose")) opts.add(Options.VERBOSE); else if (arg.startsWith("-")) { throw new SoarException("Unknown option '" + arg + "'"); } else { files.add(arg); } } // If this is the top source command (user-initiated), set up the // state info and register for production events if (topLevel) { topLevelState = new TopLevelState(); events.addListener(ProductionAddedEvent.class, eventListener); events.addListener(ProductionExcisedEvent.class, eventListener); } try { for (String file : files) { source(file); } if (topLevel) { lastTopLevelCommand = Arrays.copyOf(args, args.length); } return generateResult(topLevel, opts); } finally { // Clean up top-level state if (topLevel) { topLevelState = null; events.removeListener(null, eventListener); } } }
private static EnumSet<AccessMode> calculateAccess(final FTPFile file) { final EnumSet<AccessMode> ret = EnumSet.noneOf(AccessMode.class); if (file.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)) ret.add(AccessMode.READ); if (file.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)) ret.add(AccessMode.WRITE); if (file.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)) ret.add(AccessMode.EXECUTE); return ret; }
public static EnumSet<AutoDetachType> toEnumSet(int autoDetach) { EnumSet<AutoDetachType> types = EnumSet.noneOf(AutoDetachType.class); if ((autoDetach & AutoDetach.DETACH_NONE) != 0) types.add(NONE); if ((autoDetach & AutoDetach.DETACH_CLOSE) != 0) types.add(CLOSE); if ((autoDetach & AutoDetach.DETACH_COMMIT) != 0) types.add(COMMIT); if ((autoDetach & AutoDetach.DETACH_NONTXREAD) != 0) types.add(NON_TRANSACTIONAL_READ); if ((autoDetach & AutoDetach.DETACH_ROLLBACK) != 0) types.add(ROLLBACK); return types; }
public static Set<OFGroupCapabilities> ofWireValue(int val) { EnumSet<OFGroupCapabilities> set = EnumSet.noneOf(OFGroupCapabilities.class); if ((val & SELECT_WEIGHT_VAL) != 0) set.add(OFGroupCapabilities.SELECT_WEIGHT); if ((val & SELECT_LIVENESS_VAL) != 0) set.add(OFGroupCapabilities.SELECT_LIVENESS); if ((val & CHAINING_VAL) != 0) set.add(OFGroupCapabilities.CHAINING); if ((val & CHAINING_CHECKS_VAL) != 0) set.add(OFGroupCapabilities.CHAINING_CHECKS); return Collections.unmodifiableSet(set); }
/** * Sets the loopSide of all self-loops of the component individually, depending on the side(s) * already defined for at least one port in the component. At least one portSide must be defined, * otherwise this method will run infinitely. * * @param component The connected component to process. * @return The LoopSide that is equal to the assigned portSides. Undefined, if there is not a * common side for all loops. */ private LoopSide setPortSideByConstraint(final ConnectedSelfLoopComponent component) { // Iterator over the edges of the component. // The iterator is cycling, as there is no guarantee, that (at least) one port of the current // edge has a portSide defined. If both portSides of the current edge are UNDEFINED, we will // return to it later. final Iterator<LEdge> iter = Iterators.cycle(Lists.newArrayList(component.getEdges())); // LoopSides in this component will be collected here final EnumSet<LoopSide> loopSidesInComponent = EnumSet.noneOf(LoopSide.class); while (iter.hasNext()) { final LEdge edge = iter.next(); final PortSide sourceSide = edge.getSource().getSide(); final PortSide targetSide = edge.getTarget().getSide(); if (sourceSide == PortSide.UNDEFINED) { // source side is undefined if (targetSide != PortSide.UNDEFINED) { // only targetSide is defined. Edge becomes a sideLoop on the side of target. final LoopSide side = LoopSide.fromPortSides(targetSide); edge.setProperty(InternalProperties.SPLINE_LOOPSIDE, side); edge.getSource().setSide(targetSide); loopSidesInComponent.add(side); iter.remove(); } } else { // source side is defined if (targetSide == PortSide.UNDEFINED) { // only sourceSide is defined. Edge becomes a sideLoop on the side of source. final LoopSide side = LoopSide.fromPortSides(sourceSide); edge.setProperty(InternalProperties.SPLINE_LOOPSIDE, side); edge.getTarget().setSide(sourceSide); loopSidesInComponent.add(side); iter.remove(); } else { // both sides are defined, set edge side resulting from the combination final LoopSide side = LoopSide.fromPortSide(sourceSide, targetSide); edge.setProperty(InternalProperties.SPLINE_LOOPSIDE, side); loopSidesInComponent.add(side); iter.remove(); } } } // Now all edges have a LoopSide assigned. // Check if we can find a LoopSide for the whole component. LoopSide side; if (loopSidesInComponent.size() == 1) { side = loopSidesInComponent.iterator().next(); } else { side = LoopSide.UNDEFINED; } component.setLoopSide(side, false); return side; }
private static void putType(final EnumSet<NodeType> types, final String s) { if (ANY.equals(s)) { types.addAll(EnumSet.allOf(NodeType.class)); return; } final NodeType type = NodeType.fromName(s); types.add(type); if (type == NodeType.NUMBER) types.add(NodeType.INTEGER); }
public static EnumSet<CodePageUseFlag> valueOf(int flagByte) { EnumSet<CodePageUseFlag> result = EnumSet.noneOf(CodePageUseFlag.class); if ((flagByte & 0x80) != 0) { result.add(SortOrder); } if ((flagByte & 0x08) != 0) { result.add(VariableSpaceEnable); } return result; }
private static EnumSet<QueryOption> toQueryOptions(Attributes attrs) throws NamingException { Attribute relational = attrs.get("dcmRelationalQueries"); Attribute datetime = attrs.get("dcmCombinedDateTimeMatching"); Attribute fuzzy = attrs.get("dcmFuzzySemanticMatching"); Attribute timezone = attrs.get("dcmTimezoneQueryAdjustment"); if (relational == null && datetime == null && fuzzy == null && timezone == null) return null; EnumSet<QueryOption> opts = EnumSet.noneOf(QueryOption.class); if (booleanValue(relational, false)) opts.add(QueryOption.RELATIONAL); if (booleanValue(datetime, false)) opts.add(QueryOption.DATETIME); if (booleanValue(fuzzy, false)) opts.add(QueryOption.FUZZY); if (booleanValue(timezone, false)) opts.add(QueryOption.TIMEZONE); return opts; }
@Override protected void contructPillars(Node node) { // We have very different logic than the normal // Go through all the points and see if they are fit for pillar placement for (Point p : roomInstance.getCoordinates()) { // See that we have 2 "free" neigbouring tiles EnumSet<WallSection.WallDirection> freeDirections = EnumSet.noneOf(WallSection.WallDirection.class); if (!hasSameTile(map, p.x - start.x, p.y - start.y - 1)) { // North freeDirections.add(WallSection.WallDirection.NORTH); } if (!hasSameTile(map, p.x - start.x, p.y - start.y + 1)) { // South freeDirections.add(WallSection.WallDirection.SOUTH); } if (!hasSameTile(map, p.x - start.x + 1, p.y - start.y)) { // East freeDirections.add(WallSection.WallDirection.EAST); } if (!hasSameTile(map, p.x - start.x - 1, p.y - start.y)) { // West freeDirections.add(WallSection.WallDirection.WEST); } // We may have up to 4 pillars in the same tile even, every corner gets one, no need to check // anything else // Add a pillar // Face "in" diagonally if (freeDirections.contains(WallSection.WallDirection.NORTH) && freeDirections.contains(WallSection.WallDirection.EAST)) { Quaternion quat = new Quaternion(); quat.fromAngleAxis(FastMath.PI / 2, new Vector3f(0, -1, 0)); constructPillar(node, p, quat).move(-0.15f, MapLoader.TILE_HEIGHT, -0.85f); } if (freeDirections.contains(WallSection.WallDirection.SOUTH) && freeDirections.contains(WallSection.WallDirection.EAST)) { Quaternion quat = new Quaternion(); quat.fromAngleAxis(FastMath.PI, new Vector3f(0, 1, 0)); constructPillar(node, p, quat).move(-0.15f, MapLoader.TILE_HEIGHT, -0.15f); } if (freeDirections.contains(WallSection.WallDirection.SOUTH) && freeDirections.contains(WallSection.WallDirection.WEST)) { Quaternion quat = new Quaternion(); quat.fromAngleAxis(FastMath.PI / 2, new Vector3f(0, 1, 0)); constructPillar(node, p, quat).move(-0.85f, MapLoader.TILE_HEIGHT, -0.15f); } if (freeDirections.contains(WallSection.WallDirection.NORTH) && freeDirections.contains(WallSection.WallDirection.WEST)) { constructPillar(node, p, null).move(-0.85f, MapLoader.TILE_HEIGHT, -0.85f); } } }
@Test(timeout = 10000) public void testGetApplications() throws YarnException, IOException { Configuration conf = new Configuration(); final YarnClient client = new MockYarnClient(); client.init(conf); client.start(); List<ApplicationReport> expectedReports = ((MockYarnClient) client).getReports(); List<ApplicationReport> reports = client.getApplications(); Assert.assertEquals(reports, expectedReports); Set<String> appTypes = new HashSet<String>(); appTypes.add("YARN"); appTypes.add("NON-YARN"); reports = client.getApplications(appTypes, null); Assert.assertEquals(reports.size(), 2); Assert.assertTrue( (reports.get(0).getApplicationType().equals("YARN") && reports.get(1).getApplicationType().equals("NON-YARN")) || (reports.get(1).getApplicationType().equals("YARN") && reports.get(0).getApplicationType().equals("NON-YARN"))); for (ApplicationReport report : reports) { Assert.assertTrue(expectedReports.contains(report)); } EnumSet<YarnApplicationState> appStates = EnumSet.noneOf(YarnApplicationState.class); appStates.add(YarnApplicationState.FINISHED); appStates.add(YarnApplicationState.FAILED); reports = client.getApplications(null, appStates); Assert.assertEquals(reports.size(), 2); Assert.assertTrue( (reports.get(0).getApplicationType().equals("NON-YARN") && reports.get(1).getApplicationType().equals("NON-MAPREDUCE")) || (reports.get(1).getApplicationType().equals("NON-YARN") && reports.get(0).getApplicationType().equals("NON-MAPREDUCE"))); for (ApplicationReport report : reports) { Assert.assertTrue(expectedReports.contains(report)); } reports = client.getApplications(appTypes, appStates); Assert.assertEquals(reports.size(), 1); Assert.assertTrue((reports.get(0).getApplicationType().equals("NON-YARN"))); for (ApplicationReport report : reports) { Assert.assertTrue(expectedReports.contains(report)); } client.stop(); }
protected void doExecute(FeaturesService admin) throws Exception { if (version == null || version.length() == 0) { version = DEFAULT_VERSION; } EnumSet<FeaturesService.Option> options = EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh); if (noRefresh) { options.add(FeaturesService.Option.NoAutoRefreshBundles); } if (noClean) { options.add(FeaturesService.Option.NoCleanIfFailure); } admin.installFeature(name, version, options); }
public void addFilter(CardEnum e) { if (e instanceof ColorFlag) { colors.add((ColorFlag) e); } else if (e instanceof Attribute) { attributes.add((Attribute) e); } else if (e instanceof CardType) { if (e == CardType.TROOP || e == CardType.CONSTANT) { cardTypes.add(CardType.ARTIFACT); } cardTypes.add((CardType) e); } else { throw new RuntimeException("Unknown enum type"); } }
private EnumSet<ActMood> getImpliedConcepts() { if (_impliedConcepts == null) { if (_parent == null) { // then _parent2, 3 is also null _impliedConcepts = EnumSet.of(root); _impliedConcepts.add(this); } else { _impliedConcepts = EnumSet.copyOf(_parent.getImpliedConcepts()); _impliedConcepts.add(this); if (_parent2 != null) _impliedConcepts.addAll(_parent2.getImpliedConcepts()); if (_parent3 != null) _impliedConcepts.addAll(_parent3.getImpliedConcepts()); } } return _impliedConcepts; }
public static EnumSet<DefaultCharacterUseFlag> valueOf(int flagByte) { EnumSet<DefaultCharacterUseFlag> result = EnumSet.noneOf(DefaultCharacterUseFlag.class); if ((flagByte & 0x80) != 0) { result.add(InvalidCodedCharacter); } if ((flagByte & 0x40) != 0) { result.add(NoPresentation); } if ((flagByte & 0x20) != 0) { result.add(NoIncrement); } return result; }
public static Pair<StringContentPayload, Boolean> runVeraPDF( Path input, String profile, boolean hasFeatures) throws VeraPDFException, IOException, JAXBException { PdfBoxFoundryProvider.initialise(); PDFAFlavour flavour = PDFAFlavour.byFlavourId(profile); ValidatorConfig validatorConfig = ValidatorFactory.createConfig(flavour, true, 10); FeatureExtractorConfig featureConfig = FeatureFactory.defaultConfig(); MetadataFixerConfig fixerConfig = FixerFactory.defaultConfig(); EnumSet<TaskType> tasks = EnumSet.of(TaskType.VALIDATE); if (hasFeatures) { tasks.add(TaskType.EXTRACT_FEATURES); } ItemProcessor processor = ProcessorFactory.createProcessor( ProcessorFactory.fromValues(validatorConfig, featureConfig, fixerConfig, tasks)); ProcessorResult result = processor.process(input.toFile()); ByteArrayOutputStream os = new ByteArrayOutputStream(); boolean prettyPrint = true; ProcessorFactory.resultToXml(result, os, prettyPrint); IOUtils.closeQuietly(os); StringContentPayload s = new StringContentPayload(os.toString(RodaConstants.DEFAULT_ENCODING)); return Pair.create(s, result.getValidationResult().isCompliant()); }
private EnumSet<ExecutableType> commonExecutableTypeChecks( ValidateOnExecution validateOnExecutionAnnotation) { if (validateOnExecutionAnnotation == null) { return EnumSet.noneOf(ExecutableType.class); } EnumSet<ExecutableType> executableTypes = EnumSet.noneOf(ExecutableType.class); if (validateOnExecutionAnnotation.type().length == 0) { // HV-757 executableTypes.add(ExecutableType.NONE); } else { Collections.addAll(executableTypes, validateOnExecutionAnnotation.type()); } // IMPLICIT cannot be mixed 10.1.2 of spec - Mixing IMPLICIT and other executable types is // illegal if (executableTypes.contains(ExecutableType.IMPLICIT) && executableTypes.size() > 1) { throw log.getMixingImplicitWithOtherExecutableTypesException(); } // NONE can be removed 10.1.2 of spec - A list containing NONE and other types of executables is // equivalent to a // list containing the types of executables without NONE. if (executableTypes.contains(ExecutableType.NONE) && executableTypes.size() > 1) { executableTypes.remove(ExecutableType.NONE); } // 10.1.2 of spec - A list containing ALL and other types of executables is equivalent to a list // containing only ALL if (executableTypes.contains(ExecutableType.ALL)) { executableTypes = ALL_EXECUTABLE_TYPES; } return executableTypes; }
private EnumSet<ExecutableType> executableTypesDefinedOnMethod(Method method, boolean isGetter) { ValidateOnExecution validateOnExecutionAnnotation = method.getAnnotation(ValidateOnExecution.class); EnumSet<ExecutableType> executableTypes = commonExecutableTypeChecks(validateOnExecutionAnnotation); if (executableTypes.contains(ExecutableType.IMPLICIT)) { if (isGetter) { executableTypes.add(ExecutableType.GETTER_METHODS); } else { executableTypes.add(ExecutableType.NON_GETTER_METHODS); } } return executableTypes; }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); if (in.getVersion().before(Version.V_1_4_0)) { // term vector used to read & write the index twice, here and in the parent class in.readString(); } type = in.readString(); id = in.readString(); if (in.getVersion().onOrAfter(Version.V_1_4_0)) { if (in.readBoolean()) { doc = in.readBytesReference(); } } routing = in.readOptionalString(); preference = in.readOptionalString(); long flags = in.readVLong(); flagsEnum.clear(); for (Flag flag : Flag.values()) { if ((flags & (1 << flag.ordinal())) != 0) { flagsEnum.add(flag); } } int numSelectedFields = in.readVInt(); if (numSelectedFields > 0) { selectedFields = new HashSet<>(); for (int i = 0; i < numSelectedFields; i++) { selectedFields.add(in.readString()); } } }
public void initialize() { if (GLContext.getCapabilities().OpenGL12) { gl12 = true; } // Default values for certain GL state. glShadeModel(GL_SMOOTH); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Enable rescaling/normaling of normal vectors. // Fixes lighting issues with scaled models. if (gl12) { glEnable(GL12.GL_RESCALE_NORMAL); } else { glEnable(GL_NORMALIZE); } if (GLContext.getCapabilities().GL_ARB_texture_non_power_of_two) { caps.add(Caps.NonPowerOfTwoTextures); } else { logger.log( Level.WARNING, "Your graphics card does not " + "support non-power-of-2 textures. " + "Some features might not work."); } maxLights = glGetInteger(GL_MAX_LIGHTS); maxTexSize = glGetInteger(GL_MAX_TEXTURE_SIZE); }
/** * Returns the role that has the specified name. * * @throws RoleNotFoundException when the role could not be found */ public Role getRole(String roleName) throws IOException { Assert.hasLength(roleName); ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); String json = BlobUtils.getHeadContent(repo.r(), roleName + ROLE_SUFFIX); if (json == null) { throw new RoleNotFoundException(roleName); } Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create(); Map<String, Object> roleMap = gson.fromJson(json, new TypeToken<Map<String, Object>>() {}.getType()); @SuppressWarnings("unchecked") Collection<String> permissions = (Collection<String>) roleMap.get("permissions"); // $NON-NLS-1$ EnumSet<Permission> rolePermissions = EnumSet.noneOf(Permission.class); for (String permission : permissions) { rolePermissions.add(Permission.valueOf(permission)); } Role role = new Role(roleName, rolePermissions); return role; } finally { Util.closeQuietly(repo); } }
private static EnumSet<Parser.Option> parserOptions(Options options) { EnumSet<Parser.Option> parserOptions = EnumSet.noneOf(Parser.Option.class); if (options.nativeCalls) { parserOptions.add(Parser.Option.NativeCall); } return parserOptions; }
/** Add excluded color. */ @AConQATParameter(name = ConQATParamDoc.EXCLUDE_NAME, description = "Color to exclude.") public void addExcludedColor( @AConQATAttribute(name = "color", description = "The assessment color to exclude.") ETrafficLightColor color) { excludedColors.add(color); }
public void setException(String exceptionClass, String exceptionMessage) { ArgumentChecker.notNull(exceptionClass, "exceptionClass"); _exceptionClass = exceptionClass; _exceptionMessage = exceptionMessage; _exceptionStackTrace = null; _logLevels.add(LogLevel.WARN); }
/** * Returns all required stores for this DAO by computing dependencies of every dependencies. * * @return A set of every required stores to create a new transaction. */ public Set<S> getRequiredStores() { final HashSet<BaseAsyncDAO<S>> dependencies = new HashSet<BaseAsyncDAO<S>>(); dependencies.add(this); int previousSize = 0; int size = dependencies.size(); // Expands dependencies by adding their dependencies until no new dependency is added. while (previousSize != size) { previousSize = size; final HashSet<BaseAsyncDAO<S>> entries = new HashSet<BaseAsyncDAO<S>>(dependencies); for (final BaseAsyncDAO<S> entry : entries) { dependencies.addAll(entry.getDependencies()); } size = dependencies.size(); } final EnumSet<S> requiredStores = EnumSet.noneOf(getSchema()); for (final BaseAsyncDAO<S> dependency : dependencies) { requiredStores.add(dependency.getRequiredStore()); } return requiredStores; }