public String getVersion() { String[] parts = coo.split( ":" ); return _nn( parts[ 2 ] ); }
public String getGroupId() { String[] parts = coo.split( ":" ); return _nn( parts[ 0 ] ); }
public String getArtifactId() { String[] parts = coo.split( ":" ); return _nn( parts[ 1 ] ); }
public static Coordinates valueOf( String str ) { String[] parts = str.split( ":" ); if( parts.length < 3 ) { throw new IllegalArgumentException( "not legal coordinates group:arti:version, got: " + str ); } if( parts.length == 3 ) { return new Coordinates( _nn( parts[ 0 ] ), _nn( parts[ 1 ] ), _nn( parts[ 2 ] ) ); } if( parts.length == 4 ) { // with packaging or classifier return new Coordinates( _nn( parts[ 0 ] ), _nn( parts[ 1 ] ), _nn( parts[ 3 ] ) ); } if( parts.length == 5 ) { // with packaging and classifier return new Coordinates( _nn( parts[ 0 ] ), _nn( parts[ 1 ] ), _nn( parts[ 4 ] ) ); } throw new IllegalArgumentException( "not legal coordinates, too many ':' " + str ); }
public Optional<String> normalizeUrl( String url ) { Matcher matcher = urlPattern.matcher( url ); if( !matcher.matches() ) { return Optional.empty(); } return Optional.of( _nn( matcher.group( "relevant" ) ).toLowerCase( Locale.US )); }
@Override public MappedSomeLicense addReason( String more ) { if( more.isEmpty() ) { return this; } return new MappedSomeLicense( _nn( license ), reason + " && " + more ); }
public static LoUrl newStd( String in ) { String lower = in.toLowerCase( Locale.US ); Matcher matcher = Normalizer.urlPattern.matcher( lower ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "text does not fit as url " + in ); } return new LoUrl( _nn( matcher.group( "relevant" ) ).toLowerCase( Locale.US )); }
public Path getSnapshotTolerantDir( Path base ) { Matcher matcher = snapshot.matcher( getVersion() ); if( matcher.matches() ) { return _nn( _nn( _nn( base.resolve( getGroupId().replace( '.', '/' ) ) ).resolve( getArtifactId() ) ).resolve( matcher.group( "base" ) + "-SNAPSHOT" ) ); } return _nn( _nn( _nn( base.resolve( getGroupId().replace( '.', '/' ) ) ).resolve( getArtifactId() ) ).resolve( getVersion() ) ); }
public static String readResource( String resourceName ) { byte[] buf = new byte[ 3000000 ]; int got = 0; try( InputStream in = NonnullCheck._nn( GsonFromResource.class.getResourceAsStream( resourceName /*"/de/pfabulist/loracle/loracle.json" */) ) ) { while( true ) { int once = in.read( buf, got, 3000000 - got ); if( once < 0 ) { break; } got += once; } } catch( IOException e ) { throw Unchecked.u( e ); } return new String( buf, 0, got, StandardCharsets.UTF_8 ); } }
private LicenseID getExtended( String nameExpr ) { Matcher matcher = namePattern.matcher( nameExpr ); if( !matcher.matches() ) { // todo other licenses throw new IllegalArgumentException( "no such license: " + nameExpr ); } String name = _nn( matcher.group( "name" ) ); SingleLicense license = LOracle2.getExistingSingle( lOracle, name ). orElseThrow( () -> new IllegalArgumentException( "no such license: " + name ) ); boolean plus = matcher.group( "plus" ) != null; Optional<LicenseExclude> exception = Optional.ofNullable( matcher.group( "exception" ) ). map( str -> LOracle2.getExceptionOrThrow( lOracle, str ) ); if ( plus || exception.isPresent() ) { throw new IllegalArgumentException( "damn" ); } return license; //return lOracle.getOrLater( license, plus, exception ); }
Parsed ex = _nn( stack.pop() ); if( ex.op.isPresent() ) { throw new IllegalArgumentException( "dangling operator" ); Parsed before = _nn( stack.pop() ); stack.push( before.value( lOracle, ex.license.orElseThrow( () -> new IllegalArgumentException( "empty brackets" ) ), Parsed before = _nn( stack.pop() ); stack.push( before.value( lOracle, tok.content.orElseThrow( () -> new IllegalStateException( "text without content" ) ), Parsed before = _nn( stack.pop() ); stack.push( before.and() ); Parsed before = _nn( stack.pop() ); stack.push( before.or() ); Parsed ret = _nn( stack.pop() );
public boolean matches( Coordinates other ) { if( !coo.contains( "*" ) ) { return equals( other ); } // todo * at end List<String> txt = new ArrayList<>( Arrays.asList( coo.split( "\\*" ) ) ); if( coo.endsWith( "*" ) ) { txt.add( "" ); } if( _nn( txt.get( 0 ) ).isEmpty() ) { throw new IllegalArgumentException( "group must not start with *" ); } Pattern pat = txt.subList( 1, txt.size() ).stream(). map( Frex::txt ). reduce( Frex.txt( _nn( txt.get( 0 ) ) ), ( f, g ) -> f.then( Frex.anyBut( Frex.txt( ':' ) ).zeroOrMore() ).then( g ) ). buildCaseInsensitivePattern(); return pat.matcher( other.coo ).matches(); }