method2testcases
stringlengths
118
6.63k
### Question: TelephoneNumber { public static TelephoneNumber of(String number) { String normalized = number.replaceAll("[\\(\\)\\.\\s-_]", ""); LOGGER.debug("Normalized telephone number: {}", normalized); if (!normalized.matches("^\\+?\\d+$")) { throw new IllegalArgumentException("bad number"); } String prefix = "", s...
### Question: CIDR { public static CIDR of(String cidr) { String[] parts = cidr.split("\\/"); if (parts.length == 1) { try { InetAddress address = InetAddress.getByName(parts[0]); int length = address instanceof Inet4Address ? 32 : 128; return new CIDR(address.getAddress(), length); } catch (UnknownHostException e) { t...
### Question: AlphanumStringComparator implements Comparator<String> { @Override public int compare(String s1, String s2) { int c = 0; Matcher m1 = prefixRexp.matcher(s1); Matcher m2 = prefixRexp.matcher(s2); if (m1.find() && m2.find()) { Integer i1 = Integer.valueOf(m1.group(1)); Integer i2 = Integer.valueOf(m2.group(...
### Question: MapUtils { public static List<Map<String, List<String>>> splitToChunksOfSize(Map<String, List<String>> rawMap, int chunkSize) { List<Map<String, List<String>>> mapChunks = new LinkedList<Map<String, List<String>>>(); Set<Map.Entry<String, List<String>>> rawEntries = rawMap.entrySet(); Map<String, List<Str...
### Question: PartTreeConverter { public static String toIndexedQuery(final PartTree tree) { final StringBuilder result = new StringBuilder(); final Iterator<OrPart> orIt = tree.iterator(); while(orIt.hasNext()) { final OrPart orPart = orIt.next(); final Iterator<Part> partIt = orPart.iterator(); while(partIt.hasNext()...
### Question: SimpleDbRepositoryQuery implements RepositoryQuery { void assertNotHavingNestedQueryParameters(String query) { List<String> attributesFromQuery = QueryUtils.getQueryPartialFieldNames(query); final Class<?> domainClass = method.getDomainClazz(); for(String attribute : attributesFromQuery) { try { Field fie...
### Question: SimpleDbQueryRunner { public Object executeSingleResultQuery() { List<?> returnListFromDb = executeQuery(); return getSingleResult(returnListFromDb); } SimpleDbQueryRunner(SimpleDbOperations simpledbOperations, Class<?> domainClass, String query); SimpleDbQueryRunner(SimpleDbOperations simpledbOperations...
### Question: SimpleDbQueryRunner { Object getSingleResult(List<?> returnListFromDb) { Assert.isTrue(returnListFromDb.size() <= 1, "Select statement should return only one entity from database, returned elements size=" + returnListFromDb.size() + ", for Query=" + query); return returnListFromDb.size() > 0 ? returnListF...
### Question: SimpleDbResultConverter { public static List<Object> filterNamedAttributesAsList(List<?> domainObjects, String attributeName) { List<Object> ret = new ArrayList<Object>(); for(Object object : domainObjects) { ret.add(ReflectionUtils.callGetter(object, attributeName)); } return ret; } private SimpleDbResu...
### Question: SimpleDbResultConverter { public static Set<Object> filterNamedAttributesAsSet(List<?> domainObjects, String attributeName) { Set<Object> ret = new LinkedHashSet<Object>(); for(Object object : domainObjects) { ret.add(ReflectionUtils.callGetter(object, attributeName)); } return ret; } private SimpleDbRes...
### Question: SimpleDbResultConverter { public static List<List<Object>> toListOfListOfObject(List<?> entityList, List<String> requestedQueryFieldNames) { if(entityList.size() > 0) { List<List<Object>> rows = new ArrayList<List<Object>>(); for(Object entity : entityList) { List<Object> cols = new ArrayList<Object>(); f...
### Question: PagedResultExecution extends AbstractSimpleDbQueryExecution { @Override protected Object doExecute(SimpleDbQueryMethod queryMethod, SimpleDbQueryRunner queryRunner) { final Page<?> pagedResult = queryRunner.executePagedQuery(); if(queryMethod.isPageQuery()) { return pagedResult; } return pagedResult.getCo...
### Question: SimpleDBAttributeConverter { public static Object decodeToPrimitiveArray(List<String> fromSimpleDbAttValues, Class<?> retType) throws ParseException { Object primitiveCollection = Array.newInstance(retType, fromSimpleDbAttValues.size()); int idx = 0; for(Iterator<String> iterator = fromSimpleDbAttValues.i...
### Question: SimpleDbAttributeValueSplitter { public static Map<String, List<String>> splitAttributeValuesWithExceedingLengths(Map<String, String> rawAttributes) { Map<String, List<String>> splitAttributes = new LinkedHashMap<String, List<String>>(); Set<Map.Entry<String, String>> rawEntries = rawAttributes.entrySet()...
### Question: QueryBuilder { @Override public String toString() { String result = query.toString(); LOGGER.debug("Created query: {}", result); return result; } QueryBuilder(SimpleDbEntityInformation<?, ?> entityInformation); QueryBuilder(SimpleDbEntityInformation<?, ?> entityInformation, boolean shouldCount); QueryBu...
### Question: EntityWrapper { public Map<String, String> serialize() { return serialize(""); } EntityWrapper(SimpleDbEntityInformation<T, ?> entityInformation, T item); EntityWrapper(SimpleDbEntityInformation<T, ?> entityInformation, T item, boolean isNested); EntityWrapper(SimpleDbEntityInformation<T, ?> entityInfor...
### Question: DomainItemBuilder { public T populateDomainItem(SimpleDbEntityInformation<T, ?> entityInformation, Item item) { return buildDomainItem(entityInformation, item); } List<T> populateDomainItems(SimpleDbEntityInformation<T, ?> entityInformation, SelectResult selectResult); T populateDomainItem(SimpleDbEntity...
### Question: Util { public static Map<String, String> objectToStringMap(Object object) { TypeReference<HashMap<String, String>> typeReference = new TypeReference<HashMap<String, String>>() {}; return objectMapper.convertValue(object, typeReference); } private Util(); static String getDefaultMusicFolder(); static Stri...
### Question: InternetRadioService { public List<InternetRadioSource> getInternetRadioSources(InternetRadio radio) { List<InternetRadioSource> sources; if (cachedSources.containsKey(radio.getId())) { LOG.debug("Got cached sources for internet radio {}!", radio.getStreamUrl()); sources = cachedSources.get(radio.getId())...
### Question: Util { public static <T> T stringMapToObject(Class<T> clazz, Map<String, String> data) { return objectMapper.convertValue(data, clazz); } private Util(); static String getDefaultMusicFolder(); static String getDefaultPodcastFolder(); static String getDefaultPlaylistFolder(); static boolean isWindows(); s...
### Question: Util { public static <T> T stringMapToValidObject(Class<T> clazz, Map<String, String> data) { T object = stringMapToObject(clazz, data); Set<ConstraintViolation<T>> validate = validator.validate(object); if (validate.isEmpty()) { return object; } else { throw new IllegalArgumentException("Created object w...
### Question: JWTSecurityService { public String addJWTToken(String uri) { return addJWTToken(UriComponentsBuilder.fromUriString(uri)).build().toString(); } @Autowired JWTSecurityService(SettingsService settingsService); static String generateKey(); static Algorithm getAlgorithm(String jwtKey); String addJWTToken(Stri...
### Question: ReadmeBuilder { @Override public String toString() { Parser markdownParser = Parser.builder().build(); Node markdownDocument = markdownParser.parse(this.markdownText); HtmlRenderer renderer = HtmlRenderer.builder().build(); return TEMPLATE.replace(README_TEMPLATE_TITLE_KEY, this.pageTitle) .replace(README...
### Question: KubernetesPlugin extends ToscanaPlugin<KubernetesLifecycle> { @Override public KubernetesLifecycle getInstance(TransformationContext context) throws Exception { return new KubernetesLifecycle(context, mapper); } @Autowired KubernetesPlugin(BaseImageMapper mapper); @Override KubernetesLifecycle getInstanc...
### Question: SudoUtils { public static Optional<String> getSudoInstallCommand(String baseImage) { String imageName = baseImage.split(":")[0]; return Optional.ofNullable(IMAGE_MAP.get(imageName)); } static Optional<String> getSudoInstallCommand(String baseImage); }### Answer: @Test public void validate() { Optional<S...
### Question: ResourceFileCreator { public HashMap<String, String> getResourceYaml() throws JsonProcessingException { HashMap<String, String> result = new HashMap<>(); for (IKubernetesResource<?> resource : resources) { result.put(resource.getName(), resource.toYaml()); } return result; } ResourceFileCreator(Collection...
### Question: MapperUtils { public static boolean anythingSet(OsCapability capability) { Optional[] optionals = { capability.getDistribution(), capability.getArchitecture(), capability.getType(), capability.getVersion() }; return Arrays.stream(optionals).anyMatch(Optional::isPresent); } static boolean anythingSet(OsCa...
### Question: CapabilityMapper { public String mapOsCapabilityToImageId(OsCapability osCapability) throws SdkClientException, ParseException, IllegalArgumentException { AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)) .withRegion(awsRegion) .build(); D...
### Question: CapabilityMapper { public String mapComputeCapabilityToInstanceType(ComputeCapability computeCapability, String distinction) throws IllegalArgumentException { Integer numCpus = computeCapability.getNumCpus().orElse(0); Integer memSize = computeCapability.getMemSizeInMb().orElse(0); final ImmutableList<Ins...
### Question: CapabilityMapper { public Integer mapComputeCapabilityToRDSAllocatedStorage(ComputeCapability computeCapability) { final Integer minSize = 20; final Integer maxSize = 6144; Integer diskSize = computeCapability.getDiskSizeInMb().orElse(minSize * 1000); diskSize = diskSize / 1000; if (diskSize > maxSize) { ...
### Question: CloudFormationFileCreator { public void writeScripts() throws IOException { writeFileUploadScript(); writeStackCreationScript(); writeDeployScript(); writeCleanUpScript(); } CloudFormationFileCreator(TransformationContext context, CloudFormationModule cfnModule); void copyFiles(); void writeScripts(); voi...
### Question: CloudFormationFileCreator { public void copyUtilScripts() throws IOException { List<String> utilScripts = IOUtils.readLines( getClass().getResourceAsStream(FILEPATH_SCRIPTS_UTIL + "scripts-list"), Charsets.UTF_8 ); logger.debug("Copying util scripts to the target artifact."); copyUtilFile(utilScripts, FIL...
### Question: CloudFormationFileCreator { public void copyFiles() { List<String> fileUploadList = getFilePaths(getFileUploadByType(cfnModule.getFileUploadList(), FROM_CSAR)); logger.debug("Checking if files need to be copied."); if (!fileUploadList.isEmpty()) { logger.debug("Files to be copied found. Attempting to copy...
### Question: BashScript { public void append(String string) throws IOException { logger.debug("Appending {} to {}.sh", string, name); access.access(scriptPath).appendln(string).close(); } BashScript(PluginFileAccess access, String name); void append(String string); void checkEnvironment(String command); String getScri...
### Question: ZipUtility { public static boolean unzip(ZipInputStream zipIn, String destDirectory) throws IOException { File destDir = new File(destDirectory); if (!destDir.exists()) { destDir.mkdir(); } ZipEntry entry = zipIn.getNextEntry(); if (entry == null) { return false; } while (entry != null) { String filePath ...
### Question: PluginFileAccess { public void copy(String relativePath) throws IOException { copy(relativePath, relativePath); } PluginFileAccess(File sourceDir, File targetDir, Log log); void copy(String relativePath); void copy(String relativeSourcePath, String relativeTargetPath); BufferedLineWriter access(String rel...
### Question: PluginFileAccess { public BufferedLineWriter access(String relativePath) throws IOException { File target = new File(targetDir, relativePath); target.getParentFile().mkdirs(); try { return new BufferedLineWriter(new FileWriter(target, true)); } catch (FileNotFoundException e) { logger.error("Failed to cre...
### Question: PluginFileAccess { public String read(String relativePath) throws IOException { File source = new File(sourceDir, relativePath); try { return FileUtils.readFileToString(source); } catch (IOException e) { logger.error("Failed to read content from file '{}'", source); throw e; } } PluginFileAccess(File sour...
### Question: PluginFileAccess { public String getAbsolutePath(String relativePath) throws FileNotFoundException { File targetFile = new File(targetDir, relativePath); if (targetFile.exists()) { return targetFile.getAbsolutePath(); } else { throw new FileNotFoundException(String.format("File '%s' not found", targetFile...
### Question: PluginFileAccess { public void delete(String relativePath) { File file = new File(targetDir, relativePath); FileUtils.deleteQuietly(file); } PluginFileAccess(File sourceDir, File targetDir, Log log); void copy(String relativePath); void copy(String relativeSourcePath, String relativeTargetPath); BufferedL...
### Question: PluginFileAccess { public void createDirectories(String relativePath) { File targetFolder = new File(targetDir, relativePath); targetFolder.mkdirs(); } PluginFileAccess(File sourceDir, File targetDir, Log log); void copy(String relativePath); void copy(String relativeSourcePath, String relativeTargetPath)...
### Question: LogImpl implements Log { @Override public List<LogEntry> getLogEntries(int first, int last) { return getLogEntries(first, last, true); } LogImpl(File logFile); @Override void addLogEntry(LogEntry e); @Override List<LogEntry> getLogEntries(int first, int last); @Override List<LogEntry> getLogEntries(int fi...
### Question: TransformationServiceImpl implements TransformationService { @Override public Transformation createTransformation(Csar csar, Platform targetPlatform) throws PlatformNotFoundException { return transformationDao.create(csar, targetPlatform); } @Autowired TransformationServiceImpl( TransformationDao...
### Question: TransformationServiceImpl implements TransformationService { @Override public boolean startTransformation(Transformation transformation) { if (transformation.getState() == TransformationState.READY) { Future<?> taskFuture = executor.submit( new ExecutionTask( transformation, artifactService, pluginService...
### Question: TransformationServiceImpl implements TransformationService { @Override public boolean abortTransformation(Transformation transformation) { Future<?> task = tasks.get(transformation); if (task == null) { return false; } if (task.isDone()) { return false; } return task.cancel(true); } @Autowired Transforma...
### Question: TransformationServiceImpl implements TransformationService { @Override public boolean deleteTransformation(Transformation transformation) { if (transformation.getState() == TransformationState.TRANSFORMING) { return false; } transformationDao.delete(transformation); tasks.remove(transformation); return tr...
### Question: TransformationFilesystemDao implements TransformationDao { @Override public File getRootDir(Transformation transformation) { return getRootDir(transformation.getCsar(), transformation.getPlatform()); } @Autowired TransformationFilesystemDao(PlatformService platformService, EffectiveModelFactory effective...
### Question: TransformationFilesystemDao implements TransformationDao { @Override public Transformation create(Csar csar, Platform platform) throws PlatformNotFoundException { if (!platformService.isSupported(platform)) { throw new PlatformNotFoundException(); } Optional<Transformation> oldTransformation = csar.getTra...
### Question: TransformationFilesystemDao implements TransformationDao { @Override public void delete(Transformation transformation) { transformation.getCsar().getTransformations().remove(transformation.getPlatform().id); File transformationDir = getRootDir(transformation); delete(transformationDir); } @Autowired Tran...
### Question: TransformationFilesystemDao implements TransformationDao { @Override public Optional<Transformation> find(Csar csar, Platform platform) { Set<Transformation> transformations = readFromDisk(csar); return Optional.ofNullable(transformations.stream() .filter(transformation -> transformation.getCsar().equals(...
### Question: CsarImpl implements Csar { @Override public Optional<Transformation> getTransformation(String platformId) { Transformation t = transformations.get(platformId); return Optional.ofNullable(t); } CsarImpl(File rootDir, String identifier, Log log); @Override boolean validate(); @Override Map<String, Transform...
### Question: CsarFilesystemDao implements CsarDao { @Override public Csar create(String identifier, InputStream inputStream) { csarMap.remove(identifier); File csarDir = setupDir(identifier); Csar csar = new CsarImpl(getRootDir(identifier), identifier, getLog(identifier)); File transformationDir = new File(csarDir, TR...
### Question: CsarFilesystemDao implements CsarDao { @Override public void delete(String identifier) { File csarDir = new File(dataDir, identifier); try { FileUtils.deleteDirectory(csarDir); csarMap.remove(identifier); logger.info("Deleted csar directory '{}'", csarDir); } catch (IOException e) { logger.error("Failed t...
### Question: CsarFilesystemDao implements CsarDao { @Override public Optional<Csar> find(String identifier) { Csar csar = csarMap.get(identifier); return Optional.ofNullable(csar); } @Autowired CsarFilesystemDao(Preferences preferences, @Lazy TransformationDao transformationDao); @PostConstruct void init(); @Override...
### Question: CsarFilesystemDao implements CsarDao { @Override public List<Csar> findAll() { List<Csar> csarList = new ArrayList<>(); csarList.addAll(csarMap.values()); return csarList; } @Autowired CsarFilesystemDao(Preferences preferences, @Lazy TransformationDao transformationDao); @PostConstruct void init(); @Over...
### Question: ServiceGraph extends SimpleDirectedGraph<Entity, Connection> { public Optional<Entity> getEntity(List<String> path) { Entity current = root; for (String segment : path) { Optional<Entity> child = current.getChild(segment); if (child.isPresent()) { current = child.get(); } else { return Optional.empty(); }...
### Question: ServiceGraph extends SimpleDirectedGraph<Entity, Connection> { public boolean inputsValid() { Map<String, InputProperty> inputs = getInputs(); return inputs.values().stream() .allMatch(InputProperty::isValid); } ServiceGraph(Log log); ServiceGraph(File template, Log log); void finalizeGraph(); boolean in...
### Question: NamingUtil { public static String getUniqueName(final String suggestedName, final Set<String> existingNames) { String name = suggestedName != null ? suggestedName.trim() : ""; if (name.isEmpty()) name = "UNDEFINED"; if (existingNames != null && !existingNames.isEmpty()) { if (!isNameTaken(name, existingNa...
### Question: LinearNumberInterpolator { public LinearNumberInterpolator(double lowerDomain, double upperDomain, double lowerRange, double upperRange) { this.lowerDomain = lowerDomain; this.lowerRange = lowerRange; this.upperDomain = upperDomain; this.upperRange = upperRange; } LinearNumberInterpolator(double lowerDoma...
### Question: PathUtil { private PathUtil() {} private PathUtil(); static List<Path> dataSetsRoots(Collection<DataSetParameters> dataSets); static Path commonRoot(List<Path> paths); static Path commonRoot(Path p1, Path p2); }### Answer: @Test public void testPathUtil() { { Path c = PathUtil.commonRoot(plist("/a/b/c",...
### Question: SimilarityKey { public SimilarityKey(String geneSet1, String geneSet2, String interaction, String name) { Objects.requireNonNull(geneSet1); Objects.requireNonNull(interaction); Objects.requireNonNull(geneSet2); this.geneSet1 = geneSet1; this.geneSet2 = geneSet2; this.interaction = interaction; this.name =...
### Question: SimilarityKey { @Override public int hashCode() { return Objects.hash(geneSet1.hashCode() + geneSet2.hashCode(), interaction, name); } SimilarityKey(String geneSet1, String geneSet2, String interaction, String name); String getGeneSet1(); String getGeneSet2(); String getInteraction(); boolean isCompound()...
### Question: SimilarityKey { @Override public String toString() { return isCompound() ? getCompoundName() : String.format("%s (%s_%s) %s", geneSet1, interaction, name, geneSet2); } SimilarityKey(String geneSet1, String geneSet2, String interaction, String name); String getGeneSet1(); String getGeneSet2(); String getIn...
### Question: OpenPathwayCommonsTask extends AbstractTask { public String getPathwayCommonsURL() { EnrichmentMap map = emManager.getEnrichmentMap(network.getSUID()); if(map == null) return null; int port = Integer.parseInt(cy3props.getProperties().getProperty("rest.port")); String pcBaseUri = propertyManager.getValue(P...
### Question: SpyEventHandlerSupport { void addSpyEventHandler( @Nonnull final SpyEventHandler handler ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_spyEventHandlers.contains( handler ), () -> "Arez-0102: Attempting to add handler " + handler + " that is already " + "in the list of spy handlers." )...
### Question: ObserverInfoImpl implements ObserverInfo { @Nonnull @Override public ComputableValueInfo asComputableValue() { return _observer.getComputableValue().asInfo(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); ...
### Question: ObserverInfoImpl implements ObserverInfo { @Nullable @Override public ComponentInfo getComponent() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areNativeComponentsEnabled, () -> "Arez-0108: Spy.getComponent invoked when Arez.areNativeComponentsEnabled() returns false." ); } final Component com...
### Question: ObserverInfoImpl implements ObserverInfo { @Override public int hashCode() { return _observer.hashCode(); } ObserverInfoImpl( @Nonnull final Spy spy, @Nonnull final Observer observer ); @Nonnull @Override String getName(); @Override boolean isActive(); @Override boolean isRunning(); @Override boolean isSc...
### Question: ComputableValueInfoImpl implements ComputableValueInfo { @Override public boolean isComputing() { return _computableValue.isComputing(); } ComputableValueInfoImpl( @Nonnull final ComputableValue<?> computableValue ); @Nonnull @Override String getName(); @Override boolean isComputing(); @Nonnull @Override ...
### Question: ComputableValueInfoImpl implements ComputableValueInfo { @Nonnull Transaction getTransactionComputing() { assert _computableValue.isComputing(); final Transaction transaction = getTrackerTransaction( _computableValue.getObserver() ); if ( Arez.shouldCheckInvariants() ) { invariant( () -> transaction != nu...
### Question: RoundBasedTaskExecutor { boolean runNextTask() { if ( 0 == _remainingTasksInCurrentRound ) { final int pendingTaskCount = getPendingTaskCount(); if ( 0 == pendingTaskCount ) { _currentRound = 0; return false; } else if ( _currentRound + 1 > _maxRounds ) { _currentRound = 0; onRunawayTasksDetected(); retur...
### Question: RoundBasedTaskExecutor { void runTasks() { while ( true ) { if ( !runNextTask() ) { break; } } } RoundBasedTaskExecutor( @Nonnull final TaskQueue taskQueue, final int maxRounds ); }### Answer: @Test public void runTasks() { final ArezContext context = Arez.context(); final TaskQueue taskQueue = context....
### Question: SpyImpl implements Spy { @Override public boolean isTransactionActive() { return getContext().isTransactionActive(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handler ); @Override void removeSpyEventHandler( @Nonnull final SpyEventH...
### Question: SpyImpl implements Spy { @Nonnull @Override public TransactionInfo getTransaction() { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( this::isTransactionActive, () -> "Arez-0105: Spy.getTransaction() invoked but no transaction active." ); } return getContext().getTransaction().asInfo(); } SpyImpl( ...
### Question: SpyImpl implements Spy { @Nullable @Override public ComponentInfo findComponent( @Nonnull final String type, @Nonnull final Object id ) { final Component component = getContext().findComponent( type, id ); return null != component ? component.asInfo() : null; } SpyImpl( @Nullable final ArezContext context...
### Question: SpyImpl implements Spy { @Nonnull @Override public Collection<ComponentInfo> findAllComponentsByType( @Nonnull final String type ) { final List<ComponentInfo> infos = getContext().findAllComponentsByType( type ).stream(). map( Component::asInfo ). collect( Collectors.toList() ); return Collections.unmodif...
### Question: SpyImpl implements Spy { @Nonnull @Override public Collection<TaskInfo> findAllTopLevelTasks() { return TaskInfoImpl.asUnmodifiableInfos( getContext().getTopLevelTasks().values() ); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handler ...
### Question: ComputableValueInfoImpl implements ComputableValueInfo { @Nonnull @Override public String getName() { return _computableValue.getName(); } ComputableValueInfoImpl( @Nonnull final ComputableValue<?> computableValue ); @Nonnull @Override String getName(); @Override boolean isComputing(); @Nonnull @Override ...
### Question: SpyImpl implements Spy { @Nonnull @Override public Collection<ObservableValueInfo> findAllTopLevelObservableValues() { return ObservableValueInfoImpl.asUnmodifiableInfos( getContext().getTopLevelObservables().values() ); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( ...
### Question: SpyImpl implements Spy { @Nonnull @Override public Collection<ComputableValueInfo> findAllTopLevelComputableValues() { return ComputableValueInfoImpl.asUnmodifiableInfos( getContext().getTopLevelComputableValues().values() ); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHand...
### Question: SpyImpl implements Spy { @Nonnull @Override public Collection<ObserverInfo> findAllTopLevelObservers() { return ObserverInfoImpl.asUnmodifiableInfos( getContext().getTopLevelObservers().values() ); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEvent...
### Question: SpyImpl implements Spy { @Nonnull @Override public <T> ObservableValueInfo asObservableValueInfo( @Nonnull final ObservableValue<T> observableValue ) { return observableValue.asInfo(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handl...
### Question: SpyImpl implements Spy { @Nonnull @Override public ComponentInfo asComponentInfo( @Nonnull final Component component ) { return component.asInfo(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handler ); @Override void removeSpyEventHa...
### Question: SpyImpl implements Spy { @Nonnull @Override public ObserverInfo asObserverInfo( @Nonnull final Observer observer ) { return observer.asInfo(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handler ); @Override void removeSpyEventHandler...
### Question: SpyImpl implements Spy { @Nonnull @Override public TaskInfo asTaskInfo( @Nonnull final Task task ) { return task.asInfo(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handler ); @Override void removeSpyEventHandler( @Nonnull final Spy...
### Question: SpyImpl implements Spy { @Nonnull @Override public <T> ComputableValueInfo asComputableValueInfo( @Nonnull final ComputableValue<T> computableValue ) { return computableValue.asInfo(); } SpyImpl( @Nullable final ArezContext context ); @Override void addSpyEventHandler( @Nonnull final SpyEventHandler handl...
### Question: ObserverErrorHandlerSupport implements ObserverErrorHandler { void addObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> !_handlers.contains( handler ), () -> "Arez-0096: Attempting to add handler " + handler + " that is alrea...
### Question: ComputableValueInfoImpl implements ComputableValueInfo { @Nonnull @Override public List<ObservableValueInfo> getDependencies() { if ( _computableValue.isComputing() ) { final Transaction transaction = getTransactionComputing(); final List<ObservableValue<?>> observableValues = transaction.getObservableVal...
### Question: ObserverErrorHandlerSupport implements ObserverErrorHandler { void removeObserverErrorHandler( @Nonnull final ObserverErrorHandler handler ) { if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> _handlers.contains( handler ), () -> "Arez-0097: Attempting to remove handler " + handler + " that is ...
### Question: Task extends Node { public void schedule() { if ( isIdle() ) { queueTask(); } getContext().triggerScheduler(); } Task( @Nullable final ArezContext context, @Nullable final String name, @Nonnull final SafeProcedure work, final int flags ); void schedule(); @Override void dispose(); ...
### Question: Task extends Node { void markAsQueued() { if ( Arez.shouldCheckInvariants() ) { invariant( this::isIdle, () -> "Arez-0128: Attempting to queue task named '" + getName() + "' when task is not idle." ); } _flags = Flags.setState( _flags, Flags.STATE_QUEUED ); } Task( @Nullable final ArezContext context, ...
### Question: Task extends Node { Task( @Nullable final ArezContext context, @Nullable final String name, @Nonnull final SafeProcedure work, final int flags ) { super( context, name ); if ( Arez.shouldCheckApiInvariants() ) { apiInvariant( () -> ( ~Flags.CONFIG_FLAGS_MASK & flags ) == 0, () -> "Arez-0224: Task named '"...
### Question: Task extends Node { @Nonnull Priority getPriority() { return Priority.values()[ getPriorityIndex() ]; } Task( @Nullable final ArezContext context, @Nullable final String name, @Nonnull final SafeProcedure work, final int flags ); void schedule(); @Override void dispose(); @Override...
### Question: ActionFlags { static boolean isVerifyActionRuleValid( final int flags ) { return VERIFY_ACTION_REQUIRED == ( flags & VERIFY_ACTION_MASK ) || NO_VERIFY_ACTION_REQUIRED == ( flags & VERIFY_ACTION_MASK ); } private ActionFlags(); static final int READ_ONLY; static final int READ_WRITE; static final int NO_...
### Question: ActionFlags { static int verifyActionRule( final int flags ) { return Arez.shouldCheckApiInvariants() ? 0 != ( flags & VERIFY_ACTION_MASK ) ? 0 : VERIFY_ACTION_REQUIRED : 0; } private ActionFlags(); static final int READ_ONLY; static final int READ_WRITE; static final int NO_REPORT_RESULT; static final ...
### Question: Transaction { long getStartedAt() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areSpiesEnabled, () -> "Arez-0134: Transaction.getStartedAt() invoked when Arez.areSpiesEnabled() is false" ); } return _startedAt; } Transaction( @Nullable final ArezContext context, @Nullable final ...
### Question: Transaction { static Transaction begin( @Nonnull final ArezContext context, @Nullable final String name, final boolean mutation, @Nullable final Observer tracker ) { if ( Arez.shouldCheckApiInvariants() && Arez.shouldEnforceTransactionType() ) { if ( null != c_transaction ) { final boolean inComputableTra...
### Question: Transaction { static void commit( @Nonnull final Transaction transaction ) { if ( Arez.shouldCheckInvariants() ) { invariant( () -> null != c_transaction, () -> "Arez-0122: Attempting to commit transaction named '" + transaction.getName() + "' but no transaction is active." ); assert null != c_transaction...
### Question: ComputableValueInfoImpl implements ComputableValueInfo { @Nullable @Override public ComponentInfo getComponent() { if ( Arez.shouldCheckInvariants() ) { invariant( Arez::areNativeComponentsEnabled, () -> "Arez-0109: Spy.getComponent invoked when Arez.areNativeComponentsEnabled() returns false." ); } final...
### Question: Transaction { void beginTracking() { if ( null != _tracker ) { if ( Arez.shouldCheckInvariants() ) { _tracker.invariantDependenciesBackLink( "Pre beginTracking" ); } if ( !_tracker.isDisposing() ) { _tracker.setState( Observer.Flags.STATE_UP_TO_DATE ); } _tracker.markDependenciesLeastStaleObserverAsUpToDa...