X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2FGroupFilters.java;fp=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2FGroupFilters.java;h=67366be1f1e6958ae2ef6fa90aba4895209c8913;hp=ef6d4edbf9aa6908efb3a6da7e767c7e14d4495f;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.project/src/org/simantics/project/GroupFilters.java b/bundles/org.simantics.project/src/org/simantics/project/GroupFilters.java index ef6d4edbf..67366be1f 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/GroupFilters.java +++ b/bundles/org.simantics.project/src/org/simantics/project/GroupFilters.java @@ -1,85 +1,85 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.project; - -import java.util.Set; - -import org.simantics.project.features.registry.GroupReference; - -/** - * Utilities for constructing {@link GroupFilter} instances. - * - * @author Tuukka Lehtonen - */ -public final class GroupFilters { - - public static GroupFilter constant(final boolean answer) { - return new GroupFilter() { - @Override - public boolean accept(GroupReference ref) { - return answer; - } - }; - } - - private static final GroupFilter ACCEPT_ALL = constant(true); - private static final GroupFilter DENY_ALL = constant(false); - - public static GroupFilter acceptAll() { - return ACCEPT_ALL; - } - - public static GroupFilter denyAll() { - return DENY_ALL; - } - - /** - * Constructs a group filter that accepts only equal matches of all the - * group references provided in the argument set. - * - * @param refs the group references to accept - * @return a filter accepting the specified set of group references - */ - public static GroupFilter containsEqual(final Set refs) { - return new GroupFilter() { - @Override - public boolean accept(GroupReference ref) { - return refs.contains(ref); - } - }; - } - - /** - * Constructs a group filter that accepts groups that include one or - * more of the specified groups. Inclusion means that: - *
    - *
  1. group ID's are equal
  2. - *
  3. if tested group has a version or version range it must include - * the version in the group of the specified set
  4. - *
- * - * @param refs - * @return - */ - public static GroupFilter includesVersion(final Set refs) { - return new GroupFilter() { - @Override - public boolean accept(GroupReference range) { - for (GroupReference ref : refs) - if (range.includes(ref)) - return true; - return false; - } - }; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.project; + +import java.util.Set; + +import org.simantics.project.features.registry.GroupReference; + +/** + * Utilities for constructing {@link GroupFilter} instances. + * + * @author Tuukka Lehtonen + */ +public final class GroupFilters { + + public static GroupFilter constant(final boolean answer) { + return new GroupFilter() { + @Override + public boolean accept(GroupReference ref) { + return answer; + } + }; + } + + private static final GroupFilter ACCEPT_ALL = constant(true); + private static final GroupFilter DENY_ALL = constant(false); + + public static GroupFilter acceptAll() { + return ACCEPT_ALL; + } + + public static GroupFilter denyAll() { + return DENY_ALL; + } + + /** + * Constructs a group filter that accepts only equal matches of all the + * group references provided in the argument set. + * + * @param refs the group references to accept + * @return a filter accepting the specified set of group references + */ + public static GroupFilter containsEqual(final Set refs) { + return new GroupFilter() { + @Override + public boolean accept(GroupReference ref) { + return refs.contains(ref); + } + }; + } + + /** + * Constructs a group filter that accepts groups that include one or + * more of the specified groups. Inclusion means that: + *
    + *
  1. group ID's are equal
  2. + *
  3. if tested group has a version or version range it must include + * the version in the group of the specified set
  4. + *
+ * + * @param refs + * @return + */ + public static GroupFilter includesVersion(final Set refs) { + return new GroupFilter() { + @Override + public boolean accept(GroupReference range) { + for (GroupReference ref : refs) + if (range.includes(ref)) + return true; + return false; + } + }; + } + +}