下面列出了com.google.common.collect.Multimap#containsKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Multimap<String, String> generateFilterSetWithDimensionMap(DimensionMap dimensionMap,
Multimap<String, String> filterSet) {
Multimap<String, String> newFilterSet = HashMultimap.create();
// Dimension map gives more specified dimension information than filter set (i.e., Dimension Map should be a subset
// of filterSet), so it needs to be processed first.
if (MapUtils.isNotEmpty(dimensionMap)) {
for (Map.Entry<String, String> dimensionMapEntry : dimensionMap.entrySet()) {
newFilterSet.put(dimensionMapEntry.getKey(), dimensionMapEntry.getValue());
}
}
if (filterSet != null && filterSet.size() != 0) {
for (String key : filterSet.keySet()) {
if (!newFilterSet.containsKey(key)) {
newFilterSet.putAll(key, filterSet.get(key));
}
}
}
return newFilterSet;
}
protected void checkDispatchNonDispatchConflict(XtendClass clazz,
Multimap<DispatchHelper.DispatchSignature, JvmOperation> dispatchMethods) {
if(isIgnored(DISPATCH_PLAIN_FUNCTION_NAME_CLASH)) {
return;
}
Multimap<DispatchHelper.DispatchSignature, XtendFunction> nonDispatchMethods = HashMultimap.create();
for(XtendFunction method: filter(clazz.getMembers(), XtendFunction.class)) {
if(!method.isDispatch()) {
nonDispatchMethods.put(new DispatchHelper.DispatchSignature(method.getName(), method.getParameters().size()), method);
}
}
for (DispatchHelper.DispatchSignature dispatchSignature : dispatchMethods.keySet()) {
if (nonDispatchMethods.containsKey(dispatchSignature)) {
for (XtendFunction function : nonDispatchMethods.get(dispatchSignature))
addIssue("Non-dispatch method has same name and number of parameters as dispatch method", function,
XTEND_FUNCTION__NAME,
DISPATCH_PLAIN_FUNCTION_NAME_CLASH);
for (JvmOperation operation : dispatchMethods.get(dispatchSignature))
addIssue("Dispatch method has same name and number of parameters as non-dispatch method", associations.getXtendFunction(operation),
XTEND_FUNCTION__NAME,
DISPATCH_PLAIN_FUNCTION_NAME_CLASH);
}
}
}
@Override
public PartialResult holdsOnGuards(Multimap<GuardType, Guard> neverHolding,
Multimap<GuardType, Guard> alwaysHolding) {
if (alwaysHolding.containsKey(GuardType.IsTruthy)) {
return PartialResult.Passed;
}
if (neverHolding.containsKey(GuardType.IsNull) && neverHolding.containsKey(GuardType.IsUndefined)) {
return PartialResult.Passed;
}
if (alwaysHolding.containsKey(GuardType.IsNull)) {
return new NullDereferenceFailed(GuardType.IsNull);
}
if (alwaysHolding.containsKey(GuardType.IsUndefined)) {
return new NullDereferenceFailed(GuardType.IsUndefined);
}
return PartialResult.Unclear;
}
@Override
public PartialResult holdsOnGuards(Multimap<GuardType, Guard> neverHolding,
Multimap<GuardType, Guard> alwaysHolding) {
if (alwaysHolding.containsKey(GuardType.InState)) {
// TODO: change from GuardType to Guard
// Guard guard = alwaysHolding.get(GuardType.InState);
// Collection<String> inStates = getDeclaredStates(guard.condition, ANNOTATION_INSTATE);
// if (!inStates.isEmpty()) {
// if (guard.asserts == HoldAssertion.AlwaysHolds) {
// preStates.addAll(inStates);
// }
// if (guard.asserts == HoldAssertion.NeverHolds) {
// preStates.clear();
// preStates.addAll(inStates);
// }
// }
}
return PartialResult.Unclear;
}
protected void computeAllOperations(boolean isSuperClassBranch, Multimap<String, AbstractResolvedOperation> superClassBranchOperations,
JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations) {
for (JvmOperation operation: type.getDeclaredOperations()) {
boolean addToResult = true;
if (targetVersion.isAtLeast(JavaVersion.JAVA8)) {
addToResult = handleOverridesAndConflicts(isSuperClassBranch, operation, processedOperations, superClassBranchOperations);
} else {
String simpleName = operation.getSimpleName();
if (processedOperations.containsKey(simpleName)) {
addToResult = !isOverridden(operation, processedOperations.get(simpleName));
}
}
if (addToResult) {
BottomResolvedOperation resolvedOperation = createResolvedOperation(operation);
processedOperations.put(operation.getSimpleName(), resolvedOperation);
if (isSuperClassBranch) {
superClassBranchOperations.put(operation.getSimpleName(), resolvedOperation);
}
}
}
}
protected void computeAllFeatures(List<JvmFeature> unfiltered, Multimap<String, AbstractResolvedOperation> processedOperations, List<JvmFeature> result) {
for(JvmFeature feature: unfiltered) {
if (feature instanceof JvmOperation) {
String simpleName = feature.getSimpleName();
if (processedOperations.containsKey(simpleName)) {
if (parent.isOverridden((JvmOperation) feature, processedOperations.get(simpleName))) {
continue;
}
}
BottomResolvedOperation resolvedOperation = parent.createResolvedOperation((JvmOperation) feature, type);
processedOperations.put(simpleName, resolvedOperation);
result.add(feature);
} else {
result.add(feature);
}
}
}
private static void createAccount(PublicKey pubKey, UserInfo userInfo, String loginFilePath, String groupFilePath,
Properties props, Multimap<String, String> groupsMap) throws ManageUsersException, KeyException {
if (!userInfo.isLoginSet()) {
warnWithMessage(PROVIDED_USERNAME + IS_EMPTY_SKIPPING);
return;
}
if (!userInfo.isPasswordSet()) {
warnWithMessage("Provided password for user " + userInfo.getLogin() + IS_EMPTY_SKIPPING);
return;
}
if (!userInfo.isGroupSet()) {
warnWithMessage("Provided groups for user " + userInfo.getLogin() + IS_EMPTY_SKIPPING);
return;
}
if (props.containsKey(userInfo.getLogin())) {
warnWithMessage(USER_HEADER + userInfo.getLogin() + ALREADY_EXISTS_IN_LOGIN_FILE + loginFilePath +
UPDATING_THIS_USER_INFORMATION);
}
if (groupsMap.containsKey(userInfo.getLogin())) {
warnWithMessage(USER_HEADER + userInfo.getLogin() + ALREADY_EXISTS_IN_GROUP_FILE + groupFilePath +
UPDATING_THIS_USER_INFORMATION);
}
updateUserPassword(pubKey, userInfo.getLogin(), userInfo.getPassword(), props);
updateUserGroups(userInfo.getLogin(), userInfo.getGroups(), groupsMap);
System.out.println("Created user " + userInfo.getLogin());
}
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
boolean result = PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
if (!result) {
//processing is done here
return false;
}
//fixme right file?
PsiFile containingFile = getContainingFile();
PsiFile includedFile = BashPsiUtils.findIncludedFile(this);
Multimap<VirtualFile, PsiElement> visitedFiles = state.get(visitedIncludeFiles);
if (visitedFiles == null) {
visitedFiles = Multimaps.newListMultimap(Maps.newHashMap(), Lists::newLinkedList);
}
visitedFiles.put(containingFile.getVirtualFile(), null);
if (includedFile != null && !visitedFiles.containsKey(includedFile.getVirtualFile())) {
//mark the file as visited before the actual visit, otherwise we'll get a stack overflow
visitedFiles.put(includedFile.getVirtualFile(), this);
state = state.put(visitedIncludeFiles, visitedFiles);
return includedFile.processDeclarations(processor, state, null, place);
}
return true;
}
public static byte[] injectMethods(String name, byte[] bytes, Multimap<String, MethodInjector> injectors) {
if (injectors.containsKey(name)) {
ClassNode cnode = createClassNode(bytes);
for (MethodInjector injector : injectors.get(name)) {
MethodNode method = findMethod(injector.method, cnode);
if (method == null) {
throw new RuntimeException("Method not found: " + injector.method);
}
Game.logger().info("Injecting into {}\n{}", injector.method, printInsnList(injector.injection));
List<AbstractInsnNode> callNodes;
if (injector.before) {
callNodes = InstructionComparator.insnListFindStart(method.instructions, injector.needle);
} else {
callNodes = InstructionComparator.insnListFindEnd(method.instructions, injector.needle);
}
if (callNodes.isEmpty()) {
throw new RuntimeException("Needle not found in Haystack: " + injector.method + "\n" + printInsnList(injector.needle));
}
for (AbstractInsnNode node : callNodes) {
if (injector.before) {
Game.logger().info("Injected before: {}", printInsn(node));
method.instructions.insertBefore(node, cloneInsnList(injector.injection));
} else {
Game.logger().info("Injected after: {}+", printInsn(node));
method.instructions.insert(node, cloneInsnList(injector.injection));
}
}
}
bytes = createBytes(cnode, ClassWriter.COMPUTE_FRAMES);
}
return bytes;
}
public static void addProxyHeaders(Multimap<String, String> headers, X509Certificate clientCert) {
if (clientCert != null) {
List<String> proxiedEntitiesList = new ArrayList<>();
if (headers.containsKey(TimelyAuthenticationToken.PROXIED_ENTITIES_HEADER)) {
String proxiedEntities = HttpHeaderUtils.getSingleHeader(headers,
TimelyAuthenticationToken.PROXIED_ENTITIES_HEADER, false);
headers.removeAll(TimelyAuthenticationToken.PROXIED_ENTITIES_HEADER);
String[] preExistingProxiedEntities = ProxiedEntityUtils.splitProxiedDNs(proxiedEntities, false);
if (preExistingProxiedEntities.length > 0) {
proxiedEntitiesList.addAll(Arrays.asList(preExistingProxiedEntities));
}
}
String subjectDN = DnUtils.normalizeDN(clientCert.getSubjectDN().getName());
proxiedEntitiesList.add(subjectDN);
String[] newProxiedEntities = new String[proxiedEntitiesList.size()];
proxiedEntitiesList.toArray(newProxiedEntities);
headers.put(TimelyAuthenticationToken.PROXIED_ENTITIES_HEADER,
ProxiedEntityUtils.buildProxiedDN(newProxiedEntities));
List<String> proxiedIssuersList = new ArrayList<>();
if (headers.containsKey(TimelyAuthenticationToken.PROXIED_ISSUERS_HEADER)) {
String proxiedIssuers = HttpHeaderUtils.getSingleHeader(headers,
TimelyAuthenticationToken.PROXIED_ISSUERS_HEADER, false);
headers.removeAll(TimelyAuthenticationToken.PROXIED_ISSUERS_HEADER);
String[] preExistingProxiedIssuers = ProxiedEntityUtils.splitProxiedDNs(proxiedIssuers, false);
if (preExistingProxiedIssuers.length > 0) {
proxiedEntitiesList.addAll(Arrays.asList(preExistingProxiedIssuers));
}
}
String issuerDN = DnUtils.normalizeDN(clientCert.getIssuerDN().getName());
proxiedIssuersList.add(issuerDN);
String[] newProxiedIssuers = new String[proxiedIssuersList.size()];
proxiedIssuersList.toArray(newProxiedIssuers);
headers.put(TimelyAuthenticationToken.PROXIED_ISSUERS_HEADER,
ProxiedEntityUtils.buildProxiedDN(newProxiedIssuers));
}
}
public void peturbBalance() {
Multimap<TServerInstance,KeyExtent> serverTablets = HashMultimap.create();
for (Entry<KeyExtent,TServerInstance> entry : tabletLocs.entrySet()) {
serverTablets.put(entry.getValue(), entry.getKey());
}
ArrayList<TServerInstance> serversArray = new ArrayList<>(tservers);
for (int i = 0; i < 101; i++) {
// Find a random source server that has at least some tablets assigned to it.
TServerInstance fromServer = serversArray.get(random.nextInt(serversArray.size()));
while (!serverTablets.containsKey(fromServer)) {
fromServer = serversArray.get(random.nextInt(serversArray.size()));
}
// Find a random destination server that's different.
TServerInstance toServer;
do {
toServer = serversArray.get(random.nextInt(serversArray.size()));
} while (fromServer.equals(toServer));
ArrayList<KeyExtent> fromExtents = new ArrayList<>(serverTablets.get(fromServer));
int migrationsToMove = random.nextInt(fromExtents.size());
for (int j = 0; j < migrationsToMove; j++) {
KeyExtent extent = fromExtents.get(random.nextInt(fromExtents.size()));
fromExtents.remove(extent); // we have a local copy
assertTrue("Couldn't remove extent " + extent + " from server " + fromServer, serverTablets.remove(fromServer, extent));
assertTrue("Couldn't add extent " + extent + " to server " + toServer, serverTablets.put(toServer, extent));
assertEquals("Extent " + extent + " wasn't assigned to " + fromServer, fromServer, tabletLocs.put(extent, toServer));
}
}
}
/**
* Order {@link com.i2group.disco.user.spi.DefaultSecurityDimension}s and default dimension value ids in schema order.
*/
private Collection<com.i2group.disco.user.spi.DefaultSecurityDimension> createOrderedDefaultSecurityDimension(
SecuritySchema securitySchema, Multimap<String, String> dimensionValueIdsByDimensionId)
{
final Collection<Dimension> schemaDimensions = securitySchema.getSecurityDimensions().getAccessSecurityPermissions();
final Collection<com.i2group.disco.user.spi.DefaultSecurityDimension> result = new ArrayList<>();
for (Dimension schemaDimension : schemaDimensions)
{
final String dimensionId = schemaDimension.getId();
if (dimensionValueIdsByDimensionId.containsKey(dimensionId))
{
final Collection<String> valueIds = dimensionValueIdsByDimensionId.get(dimensionId);
final List<DimensionValue> schemaDimensionValues = schemaDimension.getValues();
final boolean isOrdered = schemaDimension.isOrdered();
final Collection<String> orderedValueIds = new ArrayList<>();
for (DimensionValue schemaDimensionValue : schemaDimensionValues)
{
final String schemaDimensionValueId = schemaDimensionValue.getId();
if (valueIds.contains(schemaDimensionValueId))
{
orderedValueIds.add(schemaDimensionValueId);
}
// Only include 1 ordered dimension value id.
if (isOrdered == true && !orderedValueIds.isEmpty())
{
break;
}
}
final com.i2group.disco.user.spi.DefaultSecurityDimension defaultSecurityDimension =
new com.i2group.disco.user.spi.DefaultSecurityDimension(dimensionId, orderedValueIds);
result.add(defaultSecurityDimension);
}
}
return result;
}
static Collection<List<Function>> findMetricFunctions(Multimap<String, List<Function>> metricFunctions,
String metricName) {
if (metricFunctions.containsKey(metricName)) {
return metricFunctions.get(metricName);
}
for (String metricNameEntry : metricFunctions.keySet()) {
String metricRegEx = getJavaRegexFromSqlRegex(metricNameEntry);
if (metricName.matches(metricRegEx)) {
return metricFunctions.get(metricNameEntry);
}
}
return null;
}
private static void checkReferencedModulesExist(Multimap<String, String> moduleDependenciesMap) {
for (String referencedModule : moduleDependenciesMap.values()) {
if (!moduleDependenciesMap.containsKey(referencedModule)) {
throw InvalidBundleException.builder()
.withUserMessage(
"Module '%s' is referenced by <uses-split> but does not exist.", referencedModule)
.build();
}
}
}
private static void copyZip(
CustomZipOutputStream out,
Path from,
Set<Path> seenFiles,
Multimap<String, Integer> allowedEntries)
throws IOException {
try (ZipInputStream in =
new ZipInputStream(new BufferedInputStream(Files.newInputStream(from)))) {
int position = 0;
for (ZipEntry entry = in.getNextEntry();
entry != null;
entry = in.getNextEntry(), position++) {
if (!allowedEntries.containsKey(entry.getName())) {
continue;
}
if (!allowedEntries.get(entry.getName()).contains(position)) {
continue;
}
if (entry.isDirectory()) {
seenFiles.add(Paths.get(entry.getName()));
}
CustomZipEntry customEntry = new CustomZipEntry(entry);
customEntry.setFakeTime();
out.putNextEntry(customEntry);
ByteStreams.copy(in, out);
out.closeEntry();
}
}
}
@Override
public PartialResult holdsOnGuards(Multimap<GuardType, Guard> neverHolding,
Multimap<GuardType, Guard> alwaysHolding) {
if (alwaysHolding.containsKey(GuardType.IsZero)) {
// TODO
// return new PartialResult.Failed(GuardType.IsZero);
}
if (neverHolding.containsKey(GuardType.IsZero)) {
return PartialResult.Passed;
}
return PartialResult.Unclear;
}
/**
* Fetch continuum anomalies whose end time is after last notify time; that is, the anomaly continues after last alert
* @param current current DateTime
* @param alertSnapShot the snapshot of the AnomalyFeed
* @return a list of continuing merged anomalies
*/
@Override
public Collection<MergedAnomalyResultDTO> getAlertCandidates(DateTime current, AlertSnapshotDTO alertSnapShot) {
if (!this.active) {
LOG.warn("ContinuumAnomalyFetcher is not active for fetching anomalies");
return Collections.emptyList();
}
if (StringUtils.isBlank(this.anomalyFetcherConfig.getAnomalySource()) ||
this.anomalyFetcherConfig.getAnomalySourceType() == null) {
LOG.error("No entry of {} or {} in the AnomalyFetcherConfig", ANOMALY_SOURCE_TYPE, ANOMALY_SOURCE);
return Collections.emptyList();
}
Period realertFrequency = TimeGranularity.fromString(
this.properties.getProperty(REALERT_FREQUENCY, DEFAULT_REALERT_FREQUENCY)).toPeriod();
long maxAnomalyRealertTimestamp = current.minus(realertFrequency).getMillis();
long lastNotifyTime = Math.max(alertSnapShot.getLastNotifyTime(), maxAnomalyRealertTimestamp);
AnomalySource anomalySourceType = anomalyFetcherConfig.getAnomalySourceType();
String anomalySource = anomalyFetcherConfig.getAnomalySource();
Predicate predicate = Predicate.AND(anomalySourceType.getPredicate(anomalySource),
Predicate.GE("endTime", lastNotifyTime));
Set<MergedAnomalyResultDTO> alertCandidates = new HashSet<>(mergedAnomalyResultDAO.findByPredicate(predicate));
Multimap<String, AnomalyNotifiedStatus> snapshot = alertSnapShot.getSnapshot();
if (snapshot.size() == 0) {
return new ArrayList<>(alertCandidates);
}
// filter out alert candidates by snapshot
Iterator<MergedAnomalyResultDTO> alertCandidatesIterator = alertCandidates.iterator();
while (alertCandidatesIterator.hasNext()) {
MergedAnomalyResultDTO mergedAnomaly = alertCandidatesIterator.next();
if (mergedAnomaly.getStartTime() > alertSnapShot.getLastNotifyTime()) {
// this anomaly start after last notify time, pass without check
continue;
}
String snapshotKey = AlertSnapshotDTO.getSnapshotKey(mergedAnomaly);
if (snapshot.containsKey(snapshotKey)){
// If the mergedAnomaly's start time is before last notify time and
// the last notify time of the metric-dimension isn't REALERT_FREQUENCY ahead, discard
long metricLastNotifyTime = alertSnapShot.getLatestStatus(snapshot, snapshotKey).getLastNotifyTime();
if (mergedAnomaly.getStartTime() < metricLastNotifyTime &&
metricLastNotifyTime < current.minus(realertFrequency).getMillis()) {
alertCandidatesIterator.remove();
}
}
}
return alertCandidates;
}
@AddCuries
@Override
public Response apply(ContainerRequestContext context) {
logger.fine("Serving dynamic request");
Multimap<String, Object> paramMap = MultivaluedMapUtils.merge(context.getUriInfo());
paramMap = resolveCuries(paramMap);
try (Transaction tx = graphDb.beginTx()) {
long start = System.currentTimeMillis();
start = System.currentTimeMillis();
Result result = cypherUtil.execute((String)path.getVendorExtensions().get("x-query"), paramMap);
logger.fine((System.currentTimeMillis() - start) + " to execute query" );
start = System.currentTimeMillis();
TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil);
Graph graph = tgu.resultToGraph(result);
tgu.setGraph(graph);
logger.fine((System.currentTimeMillis() - start) + " to convert to graph" );
start = System.currentTimeMillis();
for (String key: aspectMap.keySet()) {
if ("true".equals(getFirst(paramMap.get(key), "false"))) {
aspectMap.get(key).invoke(graph);
}
}
if (paramMap.containsKey("project")) {
@SuppressWarnings("unchecked")
Collection<String> projection = (Collection<String>)(Collection<?>)paramMap.get("project");
tgu.project(projection);
}
ArrayPropertyTransformer.transform(graph);
tx.success();
Object cacheControlNode = path.getVendorExtensions().get("x-cacheControl");
if (cacheControlNode != null) {
try {
CacheControl cacheControl = new ObjectMapper().readValue(cacheControlNode.toString(), CacheControl.class);
return Response.ok(graph).cacheControl(cacheControl).build();
}
catch (Throwable e) {
return Response.ok(graph).cacheControl(null).build();
}
}
return Response.ok(graph).cacheControl(null).build();
}
}
/**
* Fetch the list of un-notified anomalies, whose create time is after last notify time
* @param current the current DateTime
* @param alertSnapShot the snapshot of the AnomalyFeed
* @return a list of un-notified anomalies
*/
@Override
public Collection<MergedAnomalyResultDTO> getAlertCandidates(DateTime current, AlertSnapshotDTO alertSnapShot) {
if (!this.active) {
LOG.warn("UnnotifiedAnomalyFetcher is not active for fetching anomalies");
return Collections.emptyList();
}
if (StringUtils.isBlank(this.anomalyFetcherConfig.getAnomalySource()) ||
this.anomalyFetcherConfig.getAnomalySourceType() == null) {
LOG.error("No entry of {} or {} in the AnomalyFetcherConfig", ANOMALY_SOURCE_TYPE, ANOMALY_SOURCE);
return Collections.emptyList();
}
Period maxAnomalyLookBack = TimeGranularity.fromString(
this.properties.getProperty(MAXIMUM_ANOMALY_LOOK_BACK_LENGTH, DEFAULT_MAXIMUM_ANOMALY_LOOK_BACK_LENGTH)).toPeriod();
// Fetch anomalies who are created MAXIMUM_ANOMALY_LOOK_BACK_LENGTH ago
AnomalySource anomalySourceType = anomalyFetcherConfig.getAnomalySourceType();
String anomalySource = anomalyFetcherConfig.getAnomalySource();
Predicate predicate = Predicate.AND(anomalySourceType.getPredicate(anomalySource),
Predicate.GE("createTime",
new Timestamp(current.minus(maxAnomalyLookBack).getMillis())));
Set<MergedAnomalyResultDTO> alertCandidates = new HashSet<>(mergedAnomalyResultDAO.findByPredicate(predicate));
// parse snapshot to a map, getting the last notified time of given metric::dimension pair
Multimap<String, AnomalyNotifiedStatus> snapshot = alertSnapShot.getSnapshot();
if (snapshot.size() == 0) {
return new ArrayList<>(alertCandidates);
}
// filter out alert candidates by snapshot
Iterator<MergedAnomalyResultDTO> iterator = alertCandidates.iterator();
while (iterator.hasNext()) {
MergedAnomalyResultDTO mergedAnomaly = iterator.next();
String snapshotKey = AlertSnapshotDTO.getSnapshotKey(mergedAnomaly);
if (snapshot.containsKey(snapshotKey)) {
// If the mergedAnomaly's create time is before last notify time, discard
long lastNotifyTime = alertSnapShot.getLatestStatus(snapshot, snapshotKey).getLastNotifyTime();
if (mergedAnomaly.getCreatedTime() < lastNotifyTime) {
iterator.remove();
}
}
}
return alertCandidates;
}
public boolean isConnectedToLinkedCompany() {
Multimap<MapHex,Station> lStations;
Multimap<MapHex,Station> iStations;
NetworkGraph nwGraph = NetworkGraph.createMapGraph(getRoot());
NetworkGraph companyGraph =
NetworkGraph.createRouteGraph(nwGraph, this, true, false);
SimpleGraph<NetworkVertex, NetworkEdge> graph =
companyGraph.getGraph();
Set<NetworkVertex> verticies = graph.vertexSet();
PublicCompany_1880 linkedCompany =
(PublicCompany_1880) ((Investor_1880) this).getLinkedCompany();
if (linkedCompany != null) {
NetworkGraph linkedCompanyGraph=NetworkGraph.createRouteGraph(nwGraph, linkedCompany, true, false);
// Creating a list of stations blocked by tokens.
// The connection between investor and Linked Company is NOT blocked by any token of any company.
// A token that is counted as blocked can be reached by the company for which it blocks the route.
// Based on that logic a blocking token is reachable by both actors.
lStations = linkedCompanyGraph.getNonPassableStations();
iStations = companyGraph.getNonPassableStations();
//Case A) the token in Question from a linked Company is actually on the route of the Investor
for (BaseToken token : linkedCompany.getLaidBaseTokens()) {
Owner holder = token.getOwner();
if (!(holder instanceof Stop)) continue;
Stop stop = (Stop) holder;
for (NetworkVertex vertex : verticies) {
if (vertex.getType() == NetworkVertex.VertexType.STATION) {
if ((stop.getRelatedStation() == vertex.getStation())
&& (stop.getParent() == vertex.getHex())) {
return true;
}
}
}
}
// Case B) the Blocking Token is not from the linked Company
// so we need to check if the MapHex of a blocking station is showing up in the
// List of non Passable Stations
for (MapHex blockedHex:lStations.keys()) {
if (iStations.containsKey(blockedHex)) {
//Make sure its not an Offboard Map Hex
if (blockedHex.getCurrentTile().getColour().toString() == "RED" ) continue;
if (blockedHex.getStopName().equals("Beijing")) continue;
return true;
}
}
}
return false;
}