Search in sources :

Example 21 with BiPredicate

use of java.util.function.BiPredicate in project jena by apache.

the class AbstractRunnerFiles method getFiles.

protected final List<String> getFiles(String directory, Set<String> includes, Set<String> excludes) {
    Path src = Path.of(directory);
    BiPredicate<Path, BasicFileAttributes> predicate = (path, attr) -> attr.isRegularFile() && path.toString().endsWith(".shex");
    List<String> files = new ArrayList<>();
    if (includes.isEmpty()) {
        try {
            Files.find(src, 1, predicate).filter(p -> !excludes.contains(p.getFileName().toString())).sorted().map(Path::toString).forEach(files::add);
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        includes.forEach(fn -> files.add(fn));
    }
    return files;
}
Also used : Path(java.nio.file.Path) RunnerOneTest(org.apache.jena.arq.junit.runners.RunnerOneTest) Files(java.nio.file.Files) Set(java.util.Set) IOException(java.io.IOException) Description(org.junit.runner.Description) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Function(java.util.function.Function) StringUtils(org.apache.commons.lang3.StringUtils) IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) Directories(org.apache.jena.arq.junit.runners.Directories) ArrayList(java.util.ArrayList) BiPredicate(java.util.function.BiPredicate) List(java.util.List) Runner(org.junit.runner.Runner) ParentRunner(org.junit.runners.ParentRunner) RunNotifier(org.junit.runner.notification.RunNotifier) InitializationError(org.junit.runners.model.InitializationError) Path(java.nio.file.Path) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 22 with BiPredicate

use of java.util.function.BiPredicate in project groovy by apache.

the class StaticTypeCheckingVisitor method getLiteralResultType.

/**
 * For "{@code List<Type> x = [...]}" or "{@code Set<Type> y = [...]}", etc.
 * the literal may be composed of sub-types of {@code Type}. In these cases,
 * {@code ArrayList<Type>} is an appropriate result type for the expression.
 */
private static ClassNode getLiteralResultType(final ClassNode targetType, final ClassNode sourceType, final ClassNode baseType) {
    ClassNode resultType = sourceType.equals(baseType) ? sourceType : GenericsUtils.parameterizeType(sourceType, baseType.getPlainNodeReference());
    if (targetType.getGenericsTypes() != null && !GenericsUtils.buildWildcardType(targetType).isCompatibleWith(resultType)) {
        BiPredicate<GenericsType, GenericsType> isEqualOrSuper = (target, source) -> {
            if (target.isCompatibleWith(source.getType())) {
                return true;
            }
            if (!target.isPlaceholder() && !target.isWildcard()) {
                return GenericsUtils.buildWildcardType(getCombinedBoundType(target)).isCompatibleWith(source.getType());
            }
            return false;
        };
        GenericsType[] lgt = targetType.getGenericsTypes(), rgt = resultType.getGenericsTypes();
        if (IntStream.range(0, lgt.length).allMatch(i -> isEqualOrSuper.test(lgt[i], rgt[i]))) {
            resultType = GenericsUtils.parameterizeType(targetType, baseType.getPlainNodeReference());
        }
    }
    return resultType;
}
Also used : BigInteger_TYPE(org.codehaus.groovy.ast.ClassHelper.BigInteger_TYPE) Enumeration(java.util.Enumeration) StaticTypeCheckingSupport.applyGenericsContext(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext) StaticTypeCheckingSupport.filterMethodsByVisibility(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.filterMethodsByVisibility) Character_TYPE(org.codehaus.groovy.ast.ClassHelper.Character_TYPE) LinkedHashSet_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashSet_TYPE) InvocationWriter(org.codehaus.groovy.classgen.asm.InvocationWriter) StaticTypeCheckingSupport.chooseBestMethod(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.chooseBestMethod) StaticTypeCheckingSupport.fullyResolve(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolve) Map(java.util.Map) GeneralUtils.propX(org.codehaus.groovy.ast.tools.GeneralUtils.propX) StaticTypeCheckingSupport.prettyPrintTypeName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintTypeName) VOID_TYPE(org.codehaus.groovy.ast.ClassHelper.VOID_TYPE) PropertyNode(org.codehaus.groovy.ast.PropertyNode) COMPARE_TO(org.codehaus.groovy.syntax.Types.COMPARE_TO) UnaryMinusExpression(org.codehaus.groovy.ast.expr.UnaryMinusExpression) ClosureListExpression(org.codehaus.groovy.ast.expr.ClosureListExpression) PV_FIELDS_MUTATION(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_MUTATION) ClassHelper.isPrimitiveLong(org.codehaus.groovy.ast.ClassHelper.isPrimitiveLong) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) StaticTypeCheckingSupport.findDGMMethodsForClassNode(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsForClassNode) MethodReferenceExpression(org.codehaus.groovy.ast.expr.MethodReferenceExpression) TernaryExpression(org.codehaus.groovy.ast.expr.TernaryExpression) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) ClassHelper.byte_TYPE(org.codehaus.groovy.ast.ClassHelper.byte_TYPE) GeneralUtils.elvisX(org.codehaus.groovy.ast.tools.GeneralUtils.elvisX) STRING_TYPE(org.codehaus.groovy.ast.ClassHelper.STRING_TYPE) BeanUtils.decapitalize(org.apache.groovy.util.BeanUtils.decapitalize) ClassHelper.getWrapper(org.codehaus.groovy.ast.ClassHelper.getWrapper) COMPARE_NOT_IN(org.codehaus.groovy.syntax.Types.COMPARE_NOT_IN) StaticTypeCheckingSupport.isOperationInGroup(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isOperationInGroup) COMPARE_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_EQUAL) GeneralUtils.isOrImplements(org.codehaus.groovy.ast.tools.GeneralUtils.isOrImplements) ClassHelper.isPrimitiveDouble(org.codehaus.groovy.ast.ClassHelper.isPrimitiveDouble) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) ClassHelper.isWrapperInteger(org.codehaus.groovy.ast.ClassHelper.isWrapperInteger) DIVIDE_EQUAL(org.codehaus.groovy.syntax.Types.DIVIDE_EQUAL) StaticTypeCheckingSupport.getOperationName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getOperationName) IMPLICIT_RECEIVER(org.codehaus.groovy.transform.stc.StaticTypesMarker.IMPLICIT_RECEIVER) StaticTypeCheckingSupport.resolveClassNodeGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.resolveClassNodeGenerics) ClassHelper.isPrimitiveShort(org.codehaus.groovy.ast.ClassHelper.isPrimitiveShort) ClosureUtils.getParametersSafe(org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe) ClassHelper.isWrapperDouble(org.codehaus.groovy.ast.ClassHelper.isWrapperDouble) Matcher_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Matcher_TYPE) LinkedHashMap(java.util.LinkedHashMap) PrefixExpression(org.codehaus.groovy.ast.expr.PrefixExpression) SystemUtil(org.apache.groovy.util.SystemUtil) ExpressionStatement(org.codehaus.groovy.ast.stmt.ExpressionStatement) PostfixExpression(org.codehaus.groovy.ast.expr.PostfixExpression) Expression(org.codehaus.groovy.ast.expr.Expression) ClassHelper.short_TYPE(org.codehaus.groovy.ast.ClassHelper.short_TYPE) StaticTypeCheckingSupport.isPowerOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isPowerOperator) Opcodes(org.objectweb.asm.Opcodes) UnaryPlusExpression(org.codehaus.groovy.ast.expr.UnaryPlusExpression) SourceUnit(org.codehaus.groovy.control.SourceUnit) ClassNode(org.codehaus.groovy.ast.ClassNode) ClassHelper.isStringType(org.codehaus.groovy.ast.ClassHelper.isStringType) ClassHelper.float_TYPE(org.codehaus.groovy.ast.ClassHelper.float_TYPE) ClassHelper.isPrimitiveInt(org.codehaus.groovy.ast.ClassHelper.isPrimitiveInt) GenericsType(org.codehaus.groovy.ast.GenericsType) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) GeneralUtils.castX(org.codehaus.groovy.ast.tools.GeneralUtils.castX) ReturnStatement(org.codehaus.groovy.ast.stmt.ReturnStatement) AnnotationConstantExpression(org.codehaus.groovy.ast.expr.AnnotationConstantExpression) UNKNOWN_PARAMETER_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.UNKNOWN_PARAMETER_TYPE) AtomicLong(java.util.concurrent.atomic.AtomicLong) DYNAMIC_RESOLUTION(org.codehaus.groovy.transform.stc.StaticTypesMarker.DYNAMIC_RESOLUTION) BitwiseNegationExpression(org.codehaus.groovy.ast.expr.BitwiseNegationExpression) ClassHelper.isFunctionalInterface(org.codehaus.groovy.ast.ClassHelper.isFunctionalInterface) Float_TYPE(org.codehaus.groovy.ast.ClassHelper.Float_TYPE) CONSTRUCTED_LAMBDA_EXPRESSION(org.codehaus.groovy.transform.stc.StaticTypesMarker.CONSTRUCTED_LAMBDA_EXPRESSION) MapExpression(org.codehaus.groovy.ast.expr.MapExpression) ClassHelper.isGStringType(org.codehaus.groovy.ast.ClassHelper.isGStringType) GenericsTypeName(org.codehaus.groovy.ast.GenericsType.GenericsTypeName) AnnotatedNode(org.codehaus.groovy.ast.AnnotatedNode) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Long_TYPE(org.codehaus.groovy.ast.ClassHelper.Long_TYPE) StaticTypeCheckingSupport.extractGenericsParameterMapOfThis(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsParameterMapOfThis) StaticTypesTransformation(org.codehaus.groovy.transform.StaticTypesTransformation) GeneralUtils.getGetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getGetterName) StaticTypeCheckingSupport.getCombinedBoundType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedBoundType) Number_TYPE(org.codehaus.groovy.ast.ClassHelper.Number_TYPE) MethodCall(org.codehaus.groovy.ast.expr.MethodCall) ClassHelper.isBigDecimalType(org.codehaus.groovy.ast.ClassHelper.isBigDecimalType) Collectors.toMap(java.util.stream.Collectors.toMap) StaticTypeCheckingSupport.evaluateExpression(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.evaluateExpression) INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_TYPE) ForStatement(org.codehaus.groovy.ast.stmt.ForStatement) PV_FIELDS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_ACCESS) StaticTypeCheckingSupport.findSetters(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findSetters) Collection(java.util.Collection) DefaultGroovyMethods(org.codehaus.groovy.runtime.DefaultGroovyMethods) Collectors(java.util.stream.Collectors) NotExpression(org.codehaus.groovy.ast.expr.NotExpression) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) Short_TYPE(org.codehaus.groovy.ast.ClassHelper.Short_TYPE) Objects(java.util.Objects) StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments) IfStatement(org.codehaus.groovy.ast.stmt.IfStatement) FieldExpression(org.codehaus.groovy.ast.expr.FieldExpression) StaticTypeCheckingSupport.isBitOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBitOperator) ClosureUtils.hasImplicitParameter(org.codehaus.groovy.ast.tools.ClosureUtils.hasImplicitParameter) StaticTypeCheckingSupport.isWildcardLeftHandSide(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isWildcardLeftHandSide) BigDecimal_TYPE(org.codehaus.groovy.ast.ClassHelper.BigDecimal_TYPE) ClassHelper.isPrimitiveByte(org.codehaus.groovy.ast.ClassHelper.isPrimitiveByte) StaticTypeCheckingSupport.getCombinedGenericsType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedGenericsType) WideningCategories.isIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isIntCategory) DynamicVariable(org.codehaus.groovy.ast.DynamicVariable) Double_TYPE(org.codehaus.groovy.ast.ClassHelper.Double_TYPE) IntStream(java.util.stream.IntStream) StaticTypeCheckingSupport.isAssignableTo(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignableTo) ClosureSignatureHint(groovy.transform.stc.ClosureSignatureHint) AnnotationNode(org.codehaus.groovy.ast.AnnotationNode) StaticTypeCheckingSupport.isBeingCompiled(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBeingCompiled) StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics) DIVIDE(org.codehaus.groovy.syntax.Types.DIVIDE) Function(java.util.function.Function) ASSIGN(org.codehaus.groovy.syntax.Types.ASSIGN) HashSet(java.util.HashSet) ClassHelper.isNumberType(org.codehaus.groovy.ast.ClassHelper.isNumberType) BiPredicate(java.util.function.BiPredicate) ELVIS_EQUAL(org.codehaus.groovy.syntax.Types.ELVIS_EQUAL) NUMBER_OPS(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.NUMBER_OPS) Tuple2(groovy.lang.Tuple2) ClassHelper.boolean_TYPE(org.codehaus.groovy.ast.ClassHelper.boolean_TYPE) PV_METHODS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_METHODS_ACCESS) ClassCodeVisitorSupport(org.codehaus.groovy.ast.ClassCodeVisitorSupport) StaticTypeCheckingSupport.checkPossibleLossOfPrecision(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkPossibleLossOfPrecision) GeneralUtils.varX(org.codehaus.groovy.ast.tools.GeneralUtils.varX) EmptyExpression(org.codehaus.groovy.ast.expr.EmptyExpression) LinkedList(java.util.LinkedList) StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics) ConstructorCallExpression(org.codehaus.groovy.ast.expr.ConstructorCallExpression) COMPARE_NOT_INSTANCEOF(org.codehaus.groovy.syntax.Types.COMPARE_NOT_INSTANCEOF) ClassHelper(org.codehaus.groovy.ast.ClassHelper) DECLARATION_INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.DECLARATION_INFERRED_TYPE) SET_TYPE(org.codehaus.groovy.ast.ClassHelper.SET_TYPE) StaticTypeCheckingSupport.isArrayOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isArrayOp) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ASTNode(org.codehaus.groovy.ast.ASTNode) TupleExpression(org.codehaus.groovy.ast.expr.TupleExpression) GeneralUtils.binX(org.codehaus.groovy.ast.tools.GeneralUtils.binX) TryCatchStatement(org.codehaus.groovy.ast.stmt.TryCatchStatement) GenericsUtils(org.codehaus.groovy.ast.tools.GenericsUtils) StringJoiner(java.util.StringJoiner) MethodPointerExpression(org.codehaus.groovy.ast.expr.MethodPointerExpression) StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams) ClassHelper.isWrapperCharacter(org.codehaus.groovy.ast.ClassHelper.isWrapperCharacter) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) MapEntryExpression(org.codehaus.groovy.ast.expr.MapEntryExpression) ClassHelper.isObjectType(org.codehaus.groovy.ast.ClassHelper.isObjectType) Arrays(java.util.Arrays) INFERRED_RETURN_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_RETURN_TYPE) StaticTypeCheckingSupport.checkCompatibleAssignmentTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkCompatibleAssignmentTypes) Closure(groovy.lang.Closure) StaticTypeCheckingSupport.getGenericsWithoutArray(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getGenericsWithoutArray) WideningCategories.isFloatingCategory(org.codehaus.groovy.ast.tools.WideningCategories.isFloatingCategory) StaticTypeCheckingSupport.isTraitSelf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isTraitSelf) RANGE_TYPE(org.codehaus.groovy.ast.ClassHelper.RANGE_TYPE) ClosureParams(groovy.transform.stc.ClosureParams) CLOSURE_ARGUMENTS(org.codehaus.groovy.transform.stc.StaticTypesMarker.CLOSURE_ARGUMENTS) INTDIV_EQUAL(org.codehaus.groovy.syntax.Types.INTDIV_EQUAL) StaticTypeCheckingSupport.extractGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections) CaseStatement(org.codehaus.groovy.ast.stmt.CaseStatement) ClassHelper.isBigIntegerType(org.codehaus.groovy.ast.ClassHelper.isBigIntegerType) Traits(org.codehaus.groovy.transform.trait.Traits) ClassHelper.char_TYPE(org.codehaus.groovy.ast.ClassHelper.char_TYPE) MINUS_MINUS(org.codehaus.groovy.syntax.Types.MINUS_MINUS) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) EnumMap(java.util.EnumMap) LIST_TYPE(org.codehaus.groovy.ast.ClassHelper.LIST_TYPE) TypeCheckingMode(groovy.transform.TypeCheckingMode) BeanUtils.capitalize(org.apache.groovy.util.BeanUtils.capitalize) PATTERN_TYPE(org.codehaus.groovy.ast.ClassHelper.PATTERN_TYPE) NamedParams(groovy.transform.NamedParams) Set(java.util.Set) Token(org.codehaus.groovy.syntax.Token) ClassHelper.isPrimitiveVoid(org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid) ClassHelper.getUnwrapper(org.codehaus.groovy.ast.ClassHelper.getUnwrapper) GeneralUtils.callX(org.codehaus.groovy.ast.tools.GeneralUtils.callX) InvocationTargetException(java.lang.reflect.InvocationTargetException) WideningCategories.isFloat(org.codehaus.groovy.ast.tools.WideningCategories.isFloat) STREAM_TYPE(org.codehaus.groovy.ast.ClassHelper.STREAM_TYPE) CLASS_Type(org.codehaus.groovy.ast.ClassHelper.CLASS_Type) StaticTypeCheckingSupport.toMethodParametersString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.toMethodParametersString) ClassHelper.isWrapperByte(org.codehaus.groovy.ast.ClassHelper.isWrapperByte) COMPARE_NOT_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_NOT_EQUAL) StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf) ClassHelper.getNextSuperClass(org.codehaus.groovy.ast.ClassHelper.getNextSuperClass) ClassHelper.isWrapperFloat(org.codehaus.groovy.ast.ClassHelper.isWrapperFloat) ClassHelper.dynamicType(org.codehaus.groovy.ast.ClassHelper.dynamicType) ClassHelper.long_TYPE(org.codehaus.groovy.ast.ClassHelper.long_TYPE) LinkedHashMap_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashMap_TYPE) StaticTypeCheckingSupport.isBoolIntrinsicOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBoolIntrinsicOp) CastExpression(org.codehaus.groovy.ast.expr.CastExpression) StaticTypeCheckingSupport.boundUnboundedWildcards(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.boundUnboundedWildcards) ReturnAdder(org.codehaus.groovy.classgen.ReturnAdder) INTDIV(org.codehaus.groovy.syntax.Types.INTDIV) StaticMethodCallExpression(org.codehaus.groovy.ast.expr.StaticMethodCallExpression) LambdaExpression(org.codehaus.groovy.ast.expr.LambdaExpression) TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.TYPE) GeneralUtils.thisPropX(org.codehaus.groovy.ast.tools.GeneralUtils.thisPropX) StaticTypeCheckingSupport.missesGenericsTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.missesGenericsTypes) MOD_EQUAL(org.codehaus.groovy.syntax.Types.MOD_EQUAL) WhileStatement(org.codehaus.groovy.ast.stmt.WhileStatement) ArrayList(java.util.ArrayList) ClosureUtils.getResolveStrategyName(org.codehaus.groovy.ast.tools.ClosureUtils.getResolveStrategyName) MethodNode(org.codehaus.groovy.ast.MethodNode) WideningCategories.isBigDecCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigDecCategory) ClassHelper.isPrimitiveFloat(org.codehaus.groovy.ast.ClassHelper.isPrimitiveFloat) KEYWORD_IN(org.codehaus.groovy.syntax.Types.KEYWORD_IN) LinkedHashSet(java.util.LinkedHashSet) Parameter(org.codehaus.groovy.ast.Parameter) MAP_TYPE(org.codehaus.groovy.ast.ClassHelper.MAP_TYPE) WideningCategories.isDoubleCategory(org.codehaus.groovy.ast.tools.WideningCategories.isDoubleCategory) EmptyStatement(org.codehaus.groovy.ast.stmt.EmptyStatement) ClassHelper.isClassType(org.codehaus.groovy.ast.ClassHelper.isClassType) ClassHelper.isPrimitiveType(org.codehaus.groovy.ast.ClassHelper.isPrimitiveType) ClassHelper.double_TYPE(org.codehaus.groovy.ast.ClassHelper.double_TYPE) ClassHelper.isPrimitiveChar(org.codehaus.groovy.ast.ClassHelper.isPrimitiveChar) WideningCategories.isLongCategory(org.codehaus.groovy.ast.tools.WideningCategories.isLongCategory) DIRECT_METHOD_CALL_TARGET(org.codehaus.groovy.transform.stc.StaticTypesMarker.DIRECT_METHOD_CALL_TARGET) WideningCategories.isNumberCategory(org.codehaus.groovy.ast.tools.WideningCategories.isNumberCategory) PLUS_PLUS(org.codehaus.groovy.syntax.Types.PLUS_PLUS) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) KEYWORD_INSTANCEOF(org.codehaus.groovy.syntax.Types.KEYWORD_INSTANCEOF) StaticTypeCheckingSupport.isAssignment(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignment) GeneralUtils.getSetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getSetterName) DELEGATION_METADATA(org.codehaus.groovy.transform.stc.StaticTypesMarker.DELEGATION_METADATA) StaticTypeCheckingSupport.lastArgMatchesVarg(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.lastArgMatchesVarg) StaticTypeCheckingSupport.isGStringOrGStringStringLUB(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isGStringOrGStringStringLUB) ClassHelper.findSAM(org.codehaus.groovy.ast.ClassHelper.findSAM) RangeExpression(org.codehaus.groovy.ast.expr.RangeExpression) ResolveVisitor(org.codehaus.groovy.control.ResolveVisitor) Variable(org.codehaus.groovy.ast.Variable) ClassHelper.isSAMType(org.codehaus.groovy.ast.ClassHelper.isSAMType) FIND_REGEX(org.codehaus.groovy.syntax.Types.FIND_REGEX) StaticTypeCheckingSupport.prettyPrintType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintType) GeneralUtils(org.codehaus.groovy.ast.tools.GeneralUtils) WideningCategories.isDouble(org.codehaus.groovy.ast.tools.WideningCategories.isDouble) Integer_TYPE(org.codehaus.groovy.ast.ClassHelper.Integer_TYPE) DelegatesTo(groovy.lang.DelegatesTo) SpreadExpression(org.codehaus.groovy.ast.expr.SpreadExpression) SUPER_MOP_METHOD_REQUIRED(org.codehaus.groovy.transform.stc.StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED) ClassHelper.isWrapperLong(org.codehaus.groovy.ast.ClassHelper.isWrapperLong) ArrayExpression(org.codehaus.groovy.ast.expr.ArrayExpression) GROOVY_OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.GROOVY_OBJECT_TYPE) GeneralUtils.args(org.codehaus.groovy.ast.tools.GeneralUtils.args) CatchStatement(org.codehaus.groovy.ast.stmt.CatchStatement) GroovyBugError(org.codehaus.groovy.GroovyBugError) READONLY_PROPERTY(org.codehaus.groovy.transform.stc.StaticTypesMarker.READONLY_PROPERTY) List(java.util.List) TypeChecked(groovy.transform.TypeChecked) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) BlockStatement(org.codehaus.groovy.ast.stmt.BlockStatement) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Statement(org.codehaus.groovy.ast.stmt.Statement) ClassHelper.isWrapperShort(org.codehaus.groovy.ast.ClassHelper.isWrapperShort) GeneralUtils.constX(org.codehaus.groovy.ast.tools.GeneralUtils.constX) ClassHelper.int_TYPE(org.codehaus.groovy.ast.ClassHelper.int_TYPE) CodeVisitorSupport(org.codehaus.groovy.ast.CodeVisitorSupport) ElvisOperatorExpression(org.codehaus.groovy.ast.expr.ElvisOperatorExpression) Collection_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Collection_TYPE) StaticTypeCheckingSupport.findTargetVariable(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findTargetVariable) WideningCategories.lowestUpperBound(org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound) HashMap(java.util.HashMap) ClassHelper.isDynamicTyped(org.codehaus.groovy.ast.ClassHelper.isDynamicTyped) TokenUtil(org.codehaus.groovy.syntax.TokenUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) StaticTypeCheckingSupport.isVargs(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isVargs) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) WideningCategories.isBigIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigIntCategory) MethodCallExpression(org.codehaus.groovy.ast.expr.MethodCallExpression) StaticTypeCheckingSupport.isCompareToBoolean(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isCompareToBoolean) StaticTypeCheckingSupport.isParameterizedWithString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithString) Byte_TYPE(org.codehaus.groovy.ast.ClassHelper.Byte_TYPE) ErrorCollector(org.codehaus.groovy.control.ErrorCollector) Iterator(java.util.Iterator) IntRange(groovy.lang.IntRange) ClosureSignatureConflictResolver(groovy.transform.stc.ClosureSignatureConflictResolver) GenericsUtils.makeClassSafe0(org.codehaus.groovy.ast.tools.GenericsUtils.makeClassSafe0) StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics) DeclarationExpression(org.codehaus.groovy.ast.expr.DeclarationExpression) StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType) StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString) NamedParam(groovy.transform.NamedParam) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) StaticTypeCheckingSupport.applyGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsConnections) StaticTypeCheckingSupport.fullyResolveType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolveType) SwitchStatement(org.codehaus.groovy.ast.stmt.SwitchStatement) StaticTypeCheckingSupport.isShiftOperation(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isShiftOperation) FieldNode(org.codehaus.groovy.ast.FieldNode) AttributeExpression(org.codehaus.groovy.ast.expr.AttributeExpression) WideningCategories(org.codehaus.groovy.ast.tools.WideningCategories) AUTOCLOSEABLE_TYPE(org.codehaus.groovy.ast.ClassHelper.AUTOCLOSEABLE_TYPE) EQUAL(org.codehaus.groovy.syntax.Types.EQUAL) MOD(org.codehaus.groovy.syntax.Types.MOD) Collections(java.util.Collections) Iterator_TYPE(org.codehaus.groovy.ast.ClassHelper.Iterator_TYPE) ArrayList_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.ArrayList_TYPE) StaticTypeCheckingSupport.findDGMMethodsForClassNode(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsForClassNode) ClassNode(org.codehaus.groovy.ast.ClassNode) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) GenericsType(org.codehaus.groovy.ast.GenericsType) StaticTypeCheckingSupport.getCombinedGenericsType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedGenericsType)

Example 23 with BiPredicate

use of java.util.function.BiPredicate in project suite by stupidsing.

the class ServerMain method handler.

private Handler handler() {
    BiPredicate<String, String> authenticate = (username, password) -> // 
    Defaults.secrets().prove(Suite.substitute("auth .0 .1", new Str(username), new Str(password)));
    Fun2<String, String, List<String>> authenticateRoles = (username, password) -> {
        return authenticate.test(username, password) ? List.of("role") : null;
    };
    var sseHeaders = new Header(// 
    PerMap.<String, PerList<String>>empty().put("Cache-Control", // 
    PerList.of("no-cache")).put("Content-Type", PerList.of("text/event-stream")));
    Handler handlerDump = request -> Response.of(Pull.from(// 
    "" + // 
    "<html>" + "<br/>method = " + // 
    request.method + "<br/>server = " + // 
    request.server + "<br/>paths = " + // 
    request.paths + "<br/>attrs = " + // 
    HttpHeaderUtil.getAttrs(request.query) + "<br/>headers = " + // 
    request.headers + "</html>"));
    Handler handlerSse = request -> Response.ofWriter(Http.S200, sseHeaders, write -> {
        new Object() {

            private int i = 8;

            private void dispatch() {
                sleep.sink2(1000l, () -> {
                    if (0 < i--) {
                        var event = "event: number\ndata: { \"i\": " + i + " }\n\n";
                        write.f(Bytes.of(event.getBytes(Utf8.charset)));
                        dispatch();
                    } else
                        write.f(null);
                });
            }
        }.dispatch();
    });
    Handler handlerStatus = request -> {
        var cfg = new TradeCfgImpl();
        var summarize = Summarize.of(cfg);
        var sbs = summarize.summarize(trade -> trade.strategy);
        return Response.of(Pull.from("<pre>" + sbs.log + new TreeMap<>(sbs.pnlByKey) + "</pre>"));
    };
    var hh = new HttpHandle();
    var hhsa = new HttpHandleSessionAuth();
    var hhta = new HttpHandleTokenAuth();
    return hh.routeByPath(// 
    PerMap.<String, Handler>empty().put("api", // 
    hhta.applyFilter("role", hh.serveText("in good shape"))).put("hello", // 
    hh.serveText("hello world")).put("html", // 
    hh.serveDir(Paths.get(FileUtil.suiteDir() + "/src/main/html"))).put("path", // 
    hh.serveDir(Tmp.root)).put("site", // 
    hhsa.getHandler(authenticate, handlerDump)).put("sse", // 
    handlerSse).put("status", // 
    handlerStatus).put("token", hh.routeByMethod(// 
    PerMap.<String, Handler>empty().put("PATCH", // 
    hhta.refreshToken(authenticateRoles)).put("POST", hhta.getToken(authenticateRoles)))));
}
Also used : Schedule(suite.os.Schedule) Sink2(primal.fp.Funs2.Sink2) LocalDateTime(java.time.LocalDateTime) Scheduler(suite.os.Scheduler) RunUtil(suite.util.RunUtil) ArrayList(java.util.ArrayList) Defaults(suite.cfg.Defaults) BiPredicate(java.util.function.BiPredicate) Http(suite.http.Http) Response(suite.http.Http.Response) SmtpServer(suite.smtp.SmtpServer) Utf8(primal.Nouns.Utf8) LocalTime(java.time.LocalTime) FileUtil(suite.os.FileUtil) Pull(primal.MoreVerbs.Pull) HttpServe(suite.http.HttpServe) Sleep(primal.Verbs.Sleep) Handler(suite.http.Http.Handler) TelegramBotMain(suite.sample.TelegramBotMain) PerMap(primal.persistent.PerMap) TradeCfgImpl(suite.trade.data.TradeCfgImpl) Files(java.nio.file.Files) HttpNio(suite.http.HttpNio) HttpHandleSessionAuth(suite.http.HttpHandleSessionAuth) Summarize(suite.trade.analysis.Summarize) HttpHandle(suite.http.HttpHandle) Start(primal.Verbs.Start) HttpHeaderUtil(suite.http.HttpHeaderUtil) Header(suite.http.Http.Header) Bytes(primal.primitive.adt.Bytes) List(java.util.List) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) HttpHandleTokenAuth(suite.http.HttpHandleTokenAuth) Fun2(primal.fp.Funs2.Fun2) PerList(primal.persistent.PerList) Str(suite.node.Str) Tmp(primal.Nouns.Tmp) HttpHandle(suite.http.HttpHandle) TradeCfgImpl(suite.trade.data.TradeCfgImpl) Handler(suite.http.Http.Handler) Str(suite.node.Str) HttpHandleSessionAuth(suite.http.HttpHandleSessionAuth) Header(suite.http.Http.Header) ArrayList(java.util.ArrayList) List(java.util.List) PerList(primal.persistent.PerList) HttpHandleTokenAuth(suite.http.HttpHandleTokenAuth)

Example 24 with BiPredicate

use of java.util.function.BiPredicate in project Payara by payara.

the class ModelInvariantsTest method addKeyValueIgnoresNull.

@Test
public void addKeyValueIgnoresNull() {
    BiPredicate<Extensible<?>, String> hasExtension = (obj, key) -> obj.getExtensions().containsKey(key);
    assertAddIgnoresNull(new CallbackImpl(), Callback::addPathItem, Callback::hasPathItem);
    assertAddIgnoresNull(new CallbackImpl(), Callback::addExtension, hasExtension);
    assertAddIgnoresNull(new ExampleImpl(), Example::addExtension, hasExtension);
    assertAddIgnoresNull(new HeaderImpl(), Header::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new HeaderImpl(), Header::addExtension, hasExtension);
    assertAddIgnoresNull(new ContactImpl(), Contact::addExtension, hasExtension);
    assertAddIgnoresNull(new InfoImpl(), Info::addExtension, hasExtension);
    assertAddIgnoresNull(new LicenseImpl(), License::addExtension, hasExtension);
    assertAddIgnoresNull(new LinkImpl(), Link::addParameter, (obj, key) -> obj.getParameters().containsKey(key));
    assertAddIgnoresNull(new LinkImpl(), Link::addExtension, hasExtension);
    assertAddIgnoresNull(new ContentImpl(), Content::addMediaType, Content::hasMediaType);
    assertAddIgnoresNull(new DiscriminatorImpl(), Discriminator::addMapping, (obj, key) -> obj.getMapping().containsKey(key));
    assertAddIgnoresNull(new EncodingImpl(), Encoding::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new EncodingImpl(), Encoding::addExtension, hasExtension);
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addEncoding, (obj, key) -> obj.getEncoding().containsKey(key));
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addExtension, hasExtension);
    assertAddIgnoresNull(new SchemaImpl(), Schema::addProperty, (obj, key) -> obj.getProperties().containsKey(key));
    assertAddIgnoresNull(new SchemaImpl(), Schema::addExtension, hasExtension);
    assertAddIgnoresNull(new XMLImpl(), XML::addExtension, hasExtension);
    assertAddIgnoresNull(new ParameterImpl(), Parameter::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new ParameterImpl(), Parameter::addExtension, hasExtension);
    assertAddIgnoresNull(new RequestBodyImpl(), RequestBody::addExtension, hasExtension);
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addLink, (obj, key) -> obj.getLinks().containsKey(key));
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addExtension, hasExtension);
    assertAddIgnoresNull(new APIResponsesImpl(), APIResponses::addAPIResponse, APIResponses::hasAPIResponse);
    assertAddIgnoresNull(new APIResponsesImpl(), APIResponses::addExtension, hasExtension);
    assertAddIgnoresNull(new OAuthFlowImpl(), OAuthFlow::addExtension, hasExtension);
    assertAddIgnoresNull(new OAuthFlowsImpl(), OAuthFlows::addExtension, hasExtension);
    assertAddIgnoresNull(new SecuritySchemeImpl(), SecurityScheme::addExtension, hasExtension);
    assertAddIgnoresNull(new ServerImpl(), Server::addExtension, hasExtension);
    assertAddIgnoresNull(new ServerVariableImpl(), ServerVariable::addExtension, hasExtension);
    assertAddIgnoresNull(new TagImpl(), Tag::addExtension, hasExtension);
    assertAddIgnoresNull(new ComponentsImpl(), Components::addCallback, (obj, key) -> obj.getCallbacks().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addLink, (obj, key) -> obj.getLinks().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addParameter, (obj, key) -> obj.getParameters().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addRequestBody, (obj, key) -> obj.getRequestBodies().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addResponse, (obj, key) -> obj.getResponses().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addSchema, (obj, key) -> obj.getSchemas().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addSecurityScheme, (obj, key) -> obj.getSecuritySchemes().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addExtension, hasExtension);
    assertAddIgnoresNull(new ExternalDocumentationImpl(), ExternalDocumentation::addExtension, hasExtension);
    assertAddIgnoresNull(new OpenAPIImpl(), OpenAPI::addExtension, hasExtension);
    assertAddIgnoresNull(new OperationImpl(), Operation::addCallback, (obj, key) -> obj.getCallbacks().containsKey(key));
    assertAddIgnoresNull(new OperationImpl(), Operation::addExtension, hasExtension);
    assertAddIgnoresNull(new PathItemImpl(), PathItem::addExtension, hasExtension);
    assertAddIgnoresNull(new PathsImpl(), Paths::addPathItem, Paths::hasPathItem);
    assertAddIgnoresNull(new PathsImpl(), Paths::addExtension, hasExtension);
}
Also used : RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) Components(org.eclipse.microprofile.openapi.models.Components) Discriminator(org.eclipse.microprofile.openapi.models.media.Discriminator) Info(org.eclipse.microprofile.openapi.models.info.Info) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl) EncodingImpl(fish.payara.microprofile.openapi.impl.model.media.EncodingImpl) HeaderImpl(fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl) License(org.eclipse.microprofile.openapi.models.info.License) PathItem(org.eclipse.microprofile.openapi.models.PathItem) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) OAuthFlowsImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowsImpl) Header(org.eclipse.microprofile.openapi.models.headers.Header) MediaTypeImpl(fish.payara.microprofile.openapi.impl.model.media.MediaTypeImpl) RequestBody(org.eclipse.microprofile.openapi.models.parameters.RequestBody) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) Contact(org.eclipse.microprofile.openapi.models.info.Contact) OAuthFlows(org.eclipse.microprofile.openapi.models.security.OAuthFlows) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI) List(java.util.List) ServerImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerImpl) TagImpl(fish.payara.microprofile.openapi.impl.model.tags.TagImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) ExternalDocumentation(org.eclipse.microprofile.openapi.models.ExternalDocumentation) Assert.assertFalse(org.junit.Assert.assertFalse) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) Server(org.eclipse.microprofile.openapi.models.servers.Server) LicenseImpl(fish.payara.microprofile.openapi.impl.model.info.LicenseImpl) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) ServerVariableImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerVariableImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement) Paths(org.eclipse.microprofile.openapi.models.Paths) APIResponse(org.eclipse.microprofile.openapi.models.responses.APIResponse) MediaType(org.eclipse.microprofile.openapi.models.media.MediaType) OAuthFlow(org.eclipse.microprofile.openapi.models.security.OAuthFlow) DiscriminatorImpl(fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl) Encoding(org.eclipse.microprofile.openapi.models.media.Encoding) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) SecurityRequirementImpl(fish.payara.microprofile.openapi.impl.model.security.SecurityRequirementImpl) Assert.assertSame(org.junit.Assert.assertSame) BiPredicate(java.util.function.BiPredicate) InfoImpl(fish.payara.microprofile.openapi.impl.model.info.InfoImpl) Operation(org.eclipse.microprofile.openapi.models.Operation) Schema(org.eclipse.microprofile.openapi.models.media.Schema) Callback(org.eclipse.microprofile.openapi.models.callbacks.Callback) Assert.assertNotNull(org.junit.Assert.assertNotNull) Content(org.eclipse.microprofile.openapi.models.media.Content) CallbackImpl(fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl) APIResponsesImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponsesImpl) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Link(org.eclipse.microprofile.openapi.models.links.Link) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) APIResponses(org.eclipse.microprofile.openapi.models.responses.APIResponses) OAuthFlowImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowImpl) ContactImpl(fish.payara.microprofile.openapi.impl.model.info.ContactImpl) XMLImpl(fish.payara.microprofile.openapi.impl.model.media.XMLImpl) Assert.assertEquals(org.junit.Assert.assertEquals) Extensible(org.eclipse.microprofile.openapi.models.Extensible) XML(org.eclipse.microprofile.openapi.models.media.XML) OAuthFlowsImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowsImpl) Server(org.eclipse.microprofile.openapi.models.servers.Server) Schema(org.eclipse.microprofile.openapi.models.media.Schema) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) License(org.eclipse.microprofile.openapi.models.info.License) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable) Components(org.eclipse.microprofile.openapi.models.Components) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) PathItem(org.eclipse.microprofile.openapi.models.PathItem) EncodingImpl(fish.payara.microprofile.openapi.impl.model.media.EncodingImpl) ExternalDocumentation(org.eclipse.microprofile.openapi.models.ExternalDocumentation) ContactImpl(fish.payara.microprofile.openapi.impl.model.info.ContactImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) MediaType(org.eclipse.microprofile.openapi.models.media.MediaType) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) Encoding(org.eclipse.microprofile.openapi.models.media.Encoding) RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) Header(org.eclipse.microprofile.openapi.models.headers.Header) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) OAuthFlow(org.eclipse.microprofile.openapi.models.security.OAuthFlow) Content(org.eclipse.microprofile.openapi.models.media.Content) MediaTypeImpl(fish.payara.microprofile.openapi.impl.model.media.MediaTypeImpl) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI) Link(org.eclipse.microprofile.openapi.models.links.Link) APIResponse(org.eclipse.microprofile.openapi.models.responses.APIResponse) CallbackImpl(fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl) HeaderImpl(fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl) APIResponsesImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponsesImpl) Operation(org.eclipse.microprofile.openapi.models.Operation) LicenseImpl(fish.payara.microprofile.openapi.impl.model.info.LicenseImpl) OAuthFlowImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowImpl) ServerImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerImpl) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) APIResponses(org.eclipse.microprofile.openapi.models.responses.APIResponses) Paths(org.eclipse.microprofile.openapi.models.Paths) RequestBody(org.eclipse.microprofile.openapi.models.parameters.RequestBody) DiscriminatorImpl(fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl) Extensible(org.eclipse.microprofile.openapi.models.Extensible) OAuthFlows(org.eclipse.microprofile.openapi.models.security.OAuthFlows) TagImpl(fish.payara.microprofile.openapi.impl.model.tags.TagImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) Info(org.eclipse.microprofile.openapi.models.info.Info) XMLImpl(fish.payara.microprofile.openapi.impl.model.media.XMLImpl) Discriminator(org.eclipse.microprofile.openapi.models.media.Discriminator) Contact(org.eclipse.microprofile.openapi.models.info.Contact) ServerVariableImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerVariableImpl) Callback(org.eclipse.microprofile.openapi.models.callbacks.Callback) XML(org.eclipse.microprofile.openapi.models.media.XML) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) InfoImpl(fish.payara.microprofile.openapi.impl.model.info.InfoImpl) Test(org.junit.Test)

Example 25 with BiPredicate

use of java.util.function.BiPredicate in project omegat by omegat-org.

the class FileUtil method buildRelativeFilesList.

public static List<String> buildRelativeFilesList(File rootDir, List<String> includes, List<String> excludes) throws IOException {
    Path root = rootDir.toPath();
    Pattern[] includeMasks = FileUtil.compileFileMasks(includes);
    Pattern[] excludeMasks = FileUtil.compileFileMasks(excludes);
    BiPredicate<Path, BasicFileAttributes> pred = (p, attr) -> {
        return p.toFile().isFile() && FileUtil.checkFileInclude(root.relativize(p).toString(), includeMasks, excludeMasks);
    };
    try (Stream<Path> stream = Files.find(root, Integer.MAX_VALUE, pred, FileVisitOption.FOLLOW_LINKS)) {
        return stream.map(p -> root.relativize(p).toString().replace('\\', '/')).sorted(StreamUtil.localeComparator(Function.identity())).collect(Collectors.toList());
    }
}
Also used : Path(java.nio.file.Path) Arrays(java.util.Arrays) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) BiPredicate(java.util.function.BiPredicate) Matcher(java.util.regex.Matcher) Charset(java.nio.charset.Charset) Map(java.util.Map) Path(java.nio.file.Path) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) FileFilter(java.io.FileFilter) Stream(java.util.stream.Stream) FileVisitOption(java.nio.file.FileVisitOption) Entry(java.util.Map.Entry) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) Comparator(java.util.Comparator) Collections(java.util.Collections) FilenameUtils(org.apache.commons.io.FilenameUtils) Pattern(java.util.regex.Pattern) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Aggregations

BiPredicate (java.util.function.BiPredicate)36 List (java.util.List)17 Collectors (java.util.stream.Collectors)16 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)12 Collections (java.util.Collections)12 Map (java.util.Map)11 Files (java.nio.file.Files)10 Objects (java.util.Objects)8 Set (java.util.Set)8 HashMap (java.util.HashMap)7 Paths (java.nio.file.Paths)6 Arrays (java.util.Arrays)6 HashSet (java.util.HashSet)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)6 Path (java.nio.file.Path)5 java.util (java.util)5 Collection (java.util.Collection)5 Function (java.util.function.Function)5