idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
11,100
public static boolean isOrSubtype ( final Class < ? extends Entity > descendant , final Class < ? extends Entity > ancestor ) { return ancestor . isAssignableFrom ( descendant ) ; }
Checks if the specified type is equal to or a descendant from the specified ancestor type .
11,101
public static boolean isSubtype ( final Class < ? extends Entity > descendant , final Class < ? extends Entity > ancestor ) { return ! ancestor . equals ( descendant ) && ancestor . isAssignableFrom ( descendant ) ; }
Checks if the specified type is a descendant from the specified ancestor type .
11,102
public static < T > EntityListener newRecursiveAttributeListener ( final NamedAttributeType < T > namedType , final Supplier < AttributeListener < T > > supplier ) { return newRecursiveAttributeListener ( namedType , supplier , Integer . MAX_VALUE ) ; }
Creates an recursive entity listener for named attribute type and the supplied attribute listener supplier with Integer . MAX_VALUE recursion limit .
11,103
public static < T > EntityListener newRecursiveAttributeListener ( final NamedAttributeType < T > namedType , final Supplier < AttributeListener < T > > supplier , final int depth ) { if ( depth <= 0 ) { throw new IllegalArgumentException ( ) ; } return new RecursiveAttributeListener < > ( namedType , supplier , depth ) ; }
Creates an recursive entity listener for named attribute type and the supplied attribute listener supplier with specified recursion limit .
11,104
public static EntityListener newRecursiveEntityListener ( final Supplier < EntityListener > supplier , final int depth ) { if ( depth <= 0 ) { throw new IllegalArgumentException ( ) ; } return new RecursiveEntityListener ( supplier , depth ) ; }
Creates a recursive entity listener for the supplied entity listener supplier and specified recursion limit .
11,105
public boolean isEqual ( String data1 , String data2 ) { return LangUtils . isEqual ( data1 , data2 ) ; }
Compare 2 data equality
11,106
protected void handleHttpRequest ( final ChannelHandlerContext channelContext , final HttpRequest request ) throws Exception { if ( isWebSocketsUpgradeRequest ( request ) ) { final Handshake handshake = findHandshake ( request ) ; if ( handshake != null ) { HttpResponse response = handshake . generateResponse ( request ) ; response . addHeader ( Names . UPGRADE , Values . WEBSOCKET ) ; response . addHeader ( Names . CONNECTION , Values . UPGRADE ) ; final ChannelPipeline pipeline = channelContext . getChannel ( ) . getPipeline ( ) ; reconfigureUpstream ( pipeline , handshake ) ; Channel channel = channelContext . getChannel ( ) ; ChannelFuture future = channel . write ( response ) ; future . addListener ( new ChannelFutureListener ( ) { public void operationComplete ( ChannelFuture future ) throws Exception { reconfigureDownstream ( pipeline , handshake ) ; pipeline . replace ( ServerHandshakeHandler . this , "websocket-disconnection-negotiator" , new WebSocketDisconnectionNegotiator ( ) ) ; forwardConnectEventUpstream ( channelContext ) ; decodeHost ( channelContext , request ) ; decodeSession ( channelContext , request ) ; } } ) ; return ; } } sendHttpResponse ( channelContext , request , new DefaultHttpResponse ( HttpVersion . HTTP_1_1 , HttpResponseStatus . FORBIDDEN ) ) ; }
Handle initial HTTP portion of the handshake .
11,107
protected Handshake findHandshake ( HttpRequest request ) { for ( Handshake handshake : this . handshakes ) { if ( handshake . matches ( request ) ) { return handshake ; } } return null ; }
Locate a matching handshake version .
11,108
protected void reconfigureUpstream ( ChannelPipeline pipeline , Handshake handshake ) { pipeline . replace ( "http-decoder" , "websockets-decoder" , handshake . newDecoder ( ) ) ; ChannelHandler [ ] additionalHandlers = handshake . newAdditionalHandlers ( ) ; String currentTail = "websockets-decoder" ; for ( ChannelHandler each : additionalHandlers ) { String handlerName = "additional-" + each . getClass ( ) . getSimpleName ( ) ; pipeline . addAfter ( currentTail , handlerName , each ) ; currentTail = handlerName ; } }
Remove HTTP handlers replace with web - socket handlers .
11,109
protected boolean isWebSocketsUpgradeRequest ( HttpRequest request ) { String connectionHeader = request . getHeader ( Names . CONNECTION ) ; String upgradeHeader = request . getHeader ( Names . UPGRADE ) ; if ( connectionHeader == null || upgradeHeader == null ) { return false ; } if ( connectionHeader . trim ( ) . toLowerCase ( ) . contains ( Values . UPGRADE . toLowerCase ( ) ) ) { if ( upgradeHeader . trim ( ) . equalsIgnoreCase ( Values . WEBSOCKET ) ) { return true ; } } return false ; }
Determine if this request represents a web - socket upgrade request .
11,110
protected void addContainerTags ( ) { final RootContainer rc = getRootContainer ( container ) ; if ( rc != null ) { tags . add ( rc ) ; } final TreeDepth parentDepth = getTreeDepth ( container ) ; tags . add ( parentDepth != null ? parentDepth . increment ( ) : TreeDepth . ROOT ) ; }
Adds tree based tags for when a non - null container is set .
11,111
protected void removeContainerTags ( ) { tags . removeOfType ( TreeMember . class ) ; tags . removeOfType ( RootContainer . class ) ; tags . removeOfType ( TreeDepth . class ) ; }
Removes tree based tags for when a null container is set .
11,112
protected void setContainer ( final EntityContainer container ) { if ( ! Objects . equals ( this . container , container ) ) { this . container = container ; if ( ! isAlive ( ) ) { return ; } if ( container == null ) { removeContainerTags ( ) ; } else { addContainerTags ( ) ; } } }
Sets the parent container for the entity .
11,113
public void uncacheProxyOfEntity ( final Entity e , final Class < ? extends Entity > type ) { cache . invalidateType ( e , type ) ; }
Uncaches the specific type proxy for an entity .
11,114
private Map < String , TrackedNode < T > > trackNode ( String path , Map < String , TrackedNode < T > > tree , Collection < NodeEvent < T > > events , int depth ) throws InterruptedException , KeeperException { if ( depth > _depth ) { if ( log . isDebugEnabled ( ) ) log . debug ( logString ( path , "max depth reached ${depth}" ) ) ; return tree ; } TrackedNode < T > oldTrackedNode = tree . get ( path ) ; try { ZKData < T > res = _zkDataReader . readData ( _zk , path , _treeWacher ) ; TrackedNode < T > newTrackedNode = new TrackedNode < T > ( path , res . getData ( ) , res . getStat ( ) , depth ) ; if ( oldTrackedNode != null ) { if ( ! _zkDataReader . isEqual ( oldTrackedNode . getData ( ) , newTrackedNode . getData ( ) ) ) { events . add ( new NodeEvent < T > ( NodeEventType . UPDATED , newTrackedNode ) ) ; } } else { events . add ( new NodeEvent < T > ( NodeEventType . ADDED , newTrackedNode ) ) ; } tree . put ( path , newTrackedNode ) ; if ( depth < _depth ) { ZKChildren children = _zk . getZKChildren ( path , _treeWacher ) ; if ( ! newTrackedNode . getStat ( ) . equals ( children . getStat ( ) ) ) newTrackedNode . setStat ( children . getStat ( ) ) ; Collections . sort ( children . getChildren ( ) ) ; for ( String child : children . getChildren ( ) ) { String childPath = PathUtils . addPaths ( path , child ) ; if ( ! tree . containsKey ( childPath ) ) trackNode ( childPath , tree , events , depth + 1 ) ; } } _lastZkTxId = Math . max ( _lastZkTxId , newTrackedNode . getZkTxId ( ) ) ; _lock . notifyAll ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( logString ( path , "start tracking " + ( depth < _depth ? "" : "leaf " ) + "node zkTxId=" + newTrackedNode . getZkTxId ( ) ) ) ; } catch ( KeeperException . NoNodeException e ) { if ( log . isDebugEnabled ( ) ) log . debug ( logString ( path , "no such node" ) ) ; tree . remove ( path ) ; if ( oldTrackedNode != null ) { events . add ( new NodeEvent < T > ( NodeEventType . DELETED , oldTrackedNode ) ) ; } } return tree ; }
Must be called from a synchronized section
11,115
public static < T > NamedAttributeType < T > newNamedTypeOf ( final String name , final Class < T > type ) { return new NamedAttributeType < > ( name , newTypeOf ( type ) ) ; }
Creates a new named type of the supplied simple type .
11,116
public static NamedAttributeType < Object > newNamedUnknownType ( final String name , final Type type ) { return new NamedAttributeType < > ( name , new AttributeType < Object > ( type ) { } ) ; }
Creates a new named unknown type .
11,117
public static < T > AttributeType < T > newTypeOf ( final Class < T > type ) { return new AttributeType < T > ( type ) { } ; }
Creates a new attribute type of the supplied simple type .
11,118
public static String requireNotEmpty ( final String str ) throws NullPointerException , IllegalArgumentException { if ( str . length ( ) == 0 ) { throw new IllegalArgumentException ( ) ; } return str ; }
Ensures the String is not null or empty .
11,119
public boolean addWaitingWork ( final T context ) { write . lock ( ) ; try { boolean result = ! waitingWork . contains ( context ) ; if ( result ) { waitingWork . add ( context ) ; workChanged . signalAll ( ) ; } return result ; } finally { write . unlock ( ) ; } }
Adds work to the queue .
11,120
public boolean isWaitingWork ( final T context ) { read . lock ( ) ; try { return waitingWork . contains ( context ) ; } finally { read . unlock ( ) ; } }
Whether the work is contained in the queue .
11,121
public boolean removeWaitingWork ( final T context ) { write . lock ( ) ; try { boolean result = waitingWork . remove ( context ) ; if ( result ) { workChanged . signalAll ( ) ; } return result ; } finally { write . unlock ( ) ; } }
Removes work from the queue .
11,122
public boolean unresolveType ( final Class < ? extends Entity > type ) { return resolved . remove ( Objects . requireNonNull ( type ) ) != null ; }
Uncaches a resolved type .
11,123
public Stat exists ( String path ) throws InterruptedException , KeeperException { return exists ( path , false ) ; }
ZooKeeper convenient calls
11,124
public ZKData < String > getZKStringData ( String path ) throws InterruptedException , KeeperException { return getZKStringData ( path , null ) ; }
Returns both the data as a string as well as the stat
11,125
public Stat createOrSetWithParents ( String path , String data , List < ACL > acl , CreateMode createMode ) throws InterruptedException , KeeperException { if ( exists ( path ) != null ) return setData ( path , data ) ; try { createWithParents ( path , data , acl , createMode ) ; return null ; } catch ( KeeperException . NodeExistsException e ) { return setData ( path , data ) ; } }
Tries to create first and if the node exists then does a setData .
11,126
public void deleteWithChildren ( String path ) throws InterruptedException , KeeperException { List < String > allChildren = findAllChildren ( path ) ; for ( String child : allChildren ) { delete ( PathUtils . addPaths ( path , child ) ) ; } delete ( path ) ; }
delete all the children if they exist
11,127
public void waitForShutdown ( Object timeout ) throws InterruptedException , IllegalStateException , TimeoutException { if ( ! _shutdown ) throw new IllegalStateException ( "call shutdown first" ) ; ConcurrentUtils . joinFor ( clock , _mainThread , timeout ) ; }
Waits for shutdown to be completed . After calling shutdown there may still be some pending work that needs to be accomplised . This method will block until it is done but no longer than the timeout .
11,128
protected boolean addWork ( final ForkJoinContext < ? > context ) { requireNotStopped ( this ) ; final boolean result = workQueue . addWaitingWork ( context ) ; if ( result ) { addWorkerIfNeeded ( ) ; } return result ; }
Adds work to the engine .
11,129
public JFreeChartRender setDomainAxis ( double lowerBound , double upperBound ) { ValueAxis valueAxis = getPlot ( ) . getDomainAxis ( ) ; valueAxis . setUpperBound ( upperBound ) ; valueAxis . setLowerBound ( lowerBound ) ; return this ; }
Sets bounds for domain axis .
11,130
public JFreeChartRender setRangeAxis ( double lowerBound , double upperBound ) { ValueAxis valueAxis = getPlot ( ) . getRangeAxis ( ) ; valueAxis . setUpperBound ( upperBound ) ; valueAxis . setLowerBound ( lowerBound ) ; return this ; }
Sets bounds for range axis .
11,131
public JFreeChartRender setStyle ( int style ) { switch ( style ) { case JFreeChartRender . STYLE_THESIS : return this . setBaseShapesVisible ( true ) . setBaseShapesFilled ( false ) . setBaseLinesVisible ( false ) . setLegendItemFont ( new Font ( "Dialog" , Font . PLAIN , 9 ) ) . setBackgroundPaint ( Color . white ) . setGridPaint ( Color . gray ) . setInsertLast ( false ) . removeLegend ( ) ; case JFreeChartRender . STYLE_THESIS_LEGEND : return this . setBaseShapesVisible ( true ) . setBaseShapesFilled ( false ) . setBaseLinesVisible ( false ) . setLegendItemFont ( new Font ( "Dialog" , Font . PLAIN , 9 ) ) . setBackgroundPaint ( Color . white ) . setGridPaint ( Color . gray ) . setInsertLast ( false ) ; default : return this ; } }
Applies prepared style to a chart .
11,132
protected CompletableFuture < R > enqueue ( final Meta meta , final T context ) { State < T , R > state = objectQueue . get ( meta . getOid ( ) ) ; if ( state != null ) { if ( state . future . isCancelled ( ) ) { objectQueue . remove ( meta . getOid ( ) , state ) ; state = null ; } } if ( state == null ) { final State < T , R > newState = new State < > ( meta , context ) ; state = objectQueue . putIfAbsent ( meta . getOid ( ) , newState ) ; if ( state == null ) { state = newState ; stateEnqueue ( true ) ; } } return state . future ; }
This method start send object metadata to server .
11,133
public BatchRes postBatch ( final BatchReq batchReq ) throws IOException { return doWork ( auth -> doRequest ( auth , new JsonPost < > ( batchReq , BatchRes . class ) , AuthHelper . join ( auth . getHref ( ) , PATH_BATCH ) ) , batchReq . getOperation ( ) ) ; }
Send batch request to the LFS - server .
11,134
public < T > T getObject ( final String hash , final StreamHandler < T > handler ) throws IOException { return doWork ( auth -> { final ObjectRes links = doRequest ( auth , new MetaGet ( ) , AuthHelper . join ( auth . getHref ( ) , PATH_OBJECTS + "/" + hash ) ) ; if ( links == null ) { throw new FileNotFoundException ( ) ; } return getObject ( new Meta ( hash , - 1 ) , links , handler ) ; } , Operation . Download ) ; }
Download object by hash .
11,135
public < T > T getObject ( final Meta meta , final Links links , final StreamHandler < T > handler ) throws IOException { final Link link = links . getLinks ( ) . get ( LinkType . Download ) ; if ( link == null ) { throw new FileNotFoundException ( ) ; } return doRequest ( link , new ObjectGet < > ( inputStream -> handler . accept ( meta != null ? new InputStreamValidator ( inputStream , meta ) : inputStream ) ) , link . getHref ( ) ) ; }
Download object by metadata .
11,136
public static Meta generateMeta ( final StreamProvider streamProvider ) throws IOException { final MessageDigest digest = sha256 ( ) ; final byte [ ] buffer = new byte [ 0x10000 ] ; long size = 0 ; try ( InputStream stream = streamProvider . getStream ( ) ) { while ( true ) { int read = stream . read ( buffer ) ; if ( read <= 0 ) break ; digest . update ( buffer , 0 , read ) ; size += read ; } } return new Meta ( new String ( Hex . encodeHex ( digest . digest ( ) ) ) , size ) ; }
Generate object metadata .
11,137
public boolean putObject ( final StreamProvider streamProvider , final Meta meta , final Links links ) throws IOException { if ( links . getLinks ( ) . containsKey ( LinkType . Download ) ) { return false ; } final Link uploadLink = links . getLinks ( ) . get ( LinkType . Upload ) ; if ( uploadLink == null ) { throw new IOException ( "Upload link not found" ) ; } doRequest ( uploadLink , new ObjectPut ( streamProvider , meta . getSize ( ) ) , uploadLink . getHref ( ) ) ; final Link verifyLink = links . getLinks ( ) . get ( LinkType . Verify ) ; if ( verifyLink != null ) { doRequest ( verifyLink , new ObjectVerify ( meta ) , verifyLink . getHref ( ) ) ; } return true ; }
Upload object by metadata .
11,138
public long getPrice ( Configuration configuration ) { long total = 0 ; for ( KnapsackItem knapsackItem : getKnapsackItems ( ) ) { if ( configuration . valueAt ( knapsackItem . getIndex ( ) ) == 1 ) { total += knapsackItem . getPrice ( ) ; } } return total ; }
Returns price of items in given configuration .
11,139
public City addDistance ( City city , Integer distance ) { this . distances . put ( city , distance ) ; return this ; }
Adds new distance to city .
11,140
protected MoveOperation counterToOperation ( int counter ) { int jobIndex = counter / ( this . problem . machines - 1 ) ; int machineIndex = counter % ( this . problem . machines - 1 ) ; if ( machineIndex >= this . configuration . valueAt ( jobIndex ) ) machineIndex ++ ; return this . problem . moveOperations . get ( jobIndex ) . get ( machineIndex ) ; }
Returns operation for given counter .
11,141
public static void randomPathFast ( int [ ] result , int size ) { for ( int i = 0 ; i < size ; i ++ ) result [ i ] = i ; for ( int k = size - 1 ; k > 0 ; k -- ) { int w = ( int ) Math . floor ( Math . random ( ) * ( k + 1 ) ) ; int temp = result [ w ] ; result [ w ] = result [ k ] ; result [ k ] = temp ; } }
generates random permutation of cities
11,142
public CompletableFuture < Meta > upload ( final StreamProvider streamProvider ) { final CompletableFuture < Meta > future = new CompletableFuture < > ( ) ; getPool ( ) . submit ( ( ) -> { try { future . complete ( Client . generateMeta ( streamProvider ) ) ; } catch ( Throwable e ) { future . completeExceptionally ( e ) ; } } ) ; return future . thenCompose ( meta -> upload ( meta , streamProvider ) ) ; }
This method computes stream metadata and upload object .
11,143
public CompletableFuture < Meta > upload ( final Meta meta , final StreamProvider streamProvider ) { return enqueue ( meta , streamProvider ) ; }
This method start uploading object to server .
11,144
public OETLProcessor parse ( final Collection < ODocument > iBeginBlocks , final ODocument iSource , final ODocument iExtractor , final Collection < ODocument > iTransformers , final ODocument iLoader , final Collection < ODocument > iEndBlocks , final OCommandContext iContext ) { if ( iExtractor == null ) throw new IllegalArgumentException ( "No Extractor configured" ) ; context = iContext != null ? iContext : createDefaultContext ( ) ; init ( ) ; try { String name ; beginBlocks = new ArrayList < OBlock > ( ) ; if ( iBeginBlocks != null ) for ( ODocument block : iBeginBlocks ) { name = block . fieldNames ( ) [ 0 ] ; final OBlock b = factory . getBlock ( name ) ; beginBlocks . add ( b ) ; configureComponent ( b , ( ODocument ) block . field ( name ) , iContext ) ; } if ( iSource != null ) { name = iSource . fieldNames ( ) [ 0 ] ; source = factory . getSource ( name ) ; configureComponent ( source , ( ODocument ) iSource . field ( name ) , iContext ) ; } else source = factory . getSource ( "input" ) ; name = iExtractor . fieldNames ( ) [ 0 ] ; extractor = factory . getExtractor ( name ) ; configureComponent ( extractor , ( ODocument ) iExtractor . field ( name ) , iContext ) ; if ( iLoader != null ) { name = iLoader . fieldNames ( ) [ 0 ] ; loader = factory . getLoader ( name ) ; configureComponent ( loader , ( ODocument ) iLoader . field ( name ) , iContext ) ; } else loader = factory . getLoader ( "output" ) ; transformers = new ArrayList < OTransformer > ( ) ; if ( iTransformers != null ) for ( ODocument t : iTransformers ) { name = t . fieldNames ( ) [ 0 ] ; final OTransformer tr = factory . getTransformer ( name ) ; transformers . add ( tr ) ; configureComponent ( tr , ( ODocument ) t . field ( name ) , iContext ) ; } endBlocks = new ArrayList < OBlock > ( ) ; if ( iEndBlocks != null ) for ( ODocument block : iEndBlocks ) { name = block . fieldNames ( ) [ 0 ] ; final OBlock b = factory . getBlock ( name ) ; endBlocks . add ( b ) ; configureComponent ( b , ( ODocument ) block . field ( name ) , iContext ) ; } } catch ( Exception e ) { throw new OConfigurationException ( "Error on creating ETL processor" , e ) ; } return this ; }
Creates an ETL processor by setting the configuration of each component .
11,145
protected boolean fill ( final Context2D context , final Attributes attr , double alpha ) { final boolean filled = attr . hasFill ( ) ; if ( ( filled ) || ( attr . isFillShapeForSelection ( ) ) ) { alpha = alpha * attr . getFillAlpha ( ) ; if ( alpha <= 0 ) { return false ; } if ( context . isSelection ( ) ) { final String color = getColorKey ( ) ; if ( null == color ) { return false ; } context . save ( ) ; context . setFillColor ( color ) ; context . fill ( ) ; context . restore ( ) ; return true ; } if ( false == filled ) { return false ; } context . save ( ) ; if ( attr . hasShadow ( ) ) { doApplyShadow ( context , attr ) ; } context . setGlobalAlpha ( alpha ) ; final String fill = attr . getFillColor ( ) ; if ( null != fill ) { context . setFillColor ( fill ) ; context . fill ( ) ; context . restore ( ) ; return true ; } final FillGradient grad = attr . getFillGradient ( ) ; if ( null != grad ) { final String type = grad . getType ( ) ; if ( LinearGradient . TYPE . equals ( type ) ) { context . setFillGradient ( grad . asLinearGradient ( ) ) ; context . fill ( ) ; context . restore ( ) ; return true ; } else if ( RadialGradient . TYPE . equals ( type ) ) { context . setFillGradient ( grad . asRadialGradient ( ) ) ; context . fill ( ) ; context . restore ( ) ; return true ; } else if ( PatternGradient . TYPE . equals ( type ) ) { context . setFillGradient ( grad . asPatternGradient ( ) ) ; context . fill ( ) ; context . restore ( ) ; return true ; } } context . restore ( ) ; } return false ; }
Fills the Shape using the passed attributes . This method will silently also fill the Shape to its unique rgb color if the context is a buffer .
11,146
protected boolean setStrokeParams ( final Context2D context , final Attributes attr , double alpha , final boolean filled ) { double width = attr . getStrokeWidth ( ) ; String color = attr . getStrokeColor ( ) ; if ( null == color ) { if ( width > 0 ) { color = LienzoCore . get ( ) . getDefaultStrokeColor ( ) ; } } else if ( width <= 0 ) { width = LienzoCore . get ( ) . getDefaultStrokeWidth ( ) ; } if ( ( null == color ) && ( width <= 0 ) ) { if ( filled ) { return false ; } color = LienzoCore . get ( ) . getDefaultStrokeColor ( ) ; width = LienzoCore . get ( ) . getDefaultStrokeWidth ( ) ; } alpha = alpha * attr . getStrokeAlpha ( ) ; if ( alpha <= 0 ) { return false ; } double offset = 0 ; if ( context . isSelection ( ) ) { color = getColorKey ( ) ; if ( null == color ) { return false ; } context . save ( ) ; offset = getSelectionStrokeOffset ( ) ; } else { context . save ( ) ; context . setGlobalAlpha ( alpha ) ; } context . setStrokeColor ( color ) ; context . setStrokeWidth ( width + offset ) ; if ( false == attr . hasExtraStrokeAttributes ( ) ) { return true ; } boolean isdashed = false ; if ( attr . isDefined ( Attribute . DASH_ARRAY ) ) { if ( LienzoCore . get ( ) . isLineDashSupported ( ) ) { final DashArray dash = attr . getDashArray ( ) ; if ( ( null != dash ) && ( dash . size ( ) > 0 ) ) { context . setLineDash ( dash ) ; if ( attr . isDefined ( Attribute . DASH_OFFSET ) ) { context . setLineDashOffset ( attr . getDashOffset ( ) ) ; } isdashed = true ; } } } if ( ( isdashed ) || ( doStrokeExtraProperties ( ) ) ) { if ( attr . isDefined ( Attribute . LINE_JOIN ) ) { context . setLineJoin ( attr . getLineJoin ( ) ) ; } if ( attr . isDefined ( Attribute . LINE_CAP ) ) { context . setLineCap ( attr . getLineCap ( ) ) ; } if ( attr . isDefined ( Attribute . MITER_LIMIT ) ) { context . setMiterLimit ( attr . getMiterLimit ( ) ) ; } } return true ; }
Sets the Shape Stroke parameters .
11,147
protected final void doApplyShadow ( final Context2D context , final Attributes attr ) { if ( ( false == isAppliedShadow ( ) ) && ( attr . hasShadow ( ) ) ) { setAppliedShadow ( true ) ; final Shadow shadow = attr . getShadow ( ) ; if ( null != shadow ) { context . setShadow ( shadow ) ; } } }
Applies this shape s Shadow .
11,148
public T setDashArray ( final double dash , final double ... dashes ) { getAttributes ( ) . setDashArray ( new DashArray ( dash , dashes ) ) ; return cast ( ) ; }
Sets the dash array with individual dash lengths .
11,149
@ SuppressWarnings ( "unchecked" ) public T moveUp ( ) { final Node < ? > parent = getParent ( ) ; if ( null != parent ) { final IContainer < ? , IPrimitive < ? > > container = ( IContainer < ? , IPrimitive < ? > > ) parent . asContainer ( ) ; if ( null != container ) { container . moveUp ( this ) ; } } return cast ( ) ; }
Moves this shape one layer up .
11,150
public T setScale ( final double x , final double y ) { getAttributes ( ) . setScale ( x , y ) ; return cast ( ) ; }
Sets this shape s scale starting at the given x and y
11,151
public T setShear ( final double x , final double y ) { getAttributes ( ) . setShear ( x , y ) ; return cast ( ) ; }
Sets this shape s shear
11,152
public T setOffset ( final double x , final double y ) { getAttributes ( ) . setOffset ( x , y ) ; return cast ( ) ; }
Sets this shape s offset at the given x and y coordinates .
11,153
public T setFillColor ( final IColor color ) { return setFillColor ( null == color ? null : color . getColorString ( ) ) ; }
Sets the fill color .
11,154
public T setStrokeColor ( final IColor color ) { return setStrokeColor ( null == color ? null : color . getColorString ( ) ) ; }
Sets the stroke color .
11,155
private static synchronized void decrementUseCount ( ) { final String methodName = "decrementUseCount" ; logger . entry ( methodName ) ; -- useCount ; if ( useCount <= 0 ) { if ( bootstrap != null ) { bootstrap . group ( ) . shutdownGracefully ( 0 , 500 , TimeUnit . MILLISECONDS ) ; } bootstrap = null ; useCount = 0 ; } logger . exit ( methodName ) ; }
Decrement the use count of the workerGroup and request a graceful shutdown once it is no longer being used by anyone .
11,156
public boolean awaitTermination ( long timeout ) throws InterruptedException { final String methodName = "awaitTermination" ; logger . entry ( methodName ) ; final boolean terminated ; if ( bootstrap != null ) { terminated = bootstrap . group ( ) . awaitTermination ( timeout , TimeUnit . SECONDS ) ; } else { terminated = true ; } logger . exit ( methodName , terminated ) ; return terminated ; }
Waits for the underlying network service to terminate .
11,157
public String getDebugString ( ) { final StringBuilder b = new StringBuilder ( ) ; boolean first = true ; for ( final ValidationError e : m_errors ) { if ( first ) { first = false ; } else { b . append ( "\n" ) ; } b . append ( e . getContext ( ) ) . append ( " - " ) . append ( e . getMessage ( ) ) ; } return b . toString ( ) ; }
Returns a string with all error messages for debugging purposes .
11,158
public static String removeJavaPackageName ( String className ) { int idx = className . lastIndexOf ( '.' ) ; if ( idx >= 0 ) { return className . substring ( idx + 1 ) ; } else { return className ; } }
Removes the package from the type name from the given type
11,159
public static Class < ? > loadProjectClass ( Project project , String className ) { URLClassLoader classLoader = getProjectClassLoader ( project ) ; if ( classLoader != null ) { try { return classLoader . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { } finally { try { classLoader . close ( ) ; } catch ( IOException e ) { } } } return null ; }
Loads a class of the given name from the project class loader or returns null if its not found
11,160
protected boolean prepare ( final Context2D context , final Attributes attr , final double alpha ) { final Point2DArray points = attr . getControlPoints ( ) ; if ( ( points != null ) && ( points . size ( ) == 3 ) ) { context . beginPath ( ) ; final Point2D p0 = points . get ( 0 ) ; final Point2D p1 = points . get ( 1 ) ; final Point2D p2 = points . get ( 2 ) ; context . moveTo ( p0 . getX ( ) , p0 . getY ( ) ) ; context . quadraticCurveTo ( p1 . getX ( ) , p1 . getY ( ) , p2 . getX ( ) , p2 . getY ( ) ) ; return true ; } return false ; }
Draws this quadratic curve
11,161
public final ImageData copy ( ) { final Context2D context = new ScratchPad ( getWidth ( ) , getHeight ( ) ) . getContext ( ) ; context . putImageData ( this , 0 , 0 ) ; return context . getImageData ( 0 , 0 , getWidth ( ) , getHeight ( ) ) ; }
ImageData can t be cloned or deep - copied it s an internal data structure and has some CRAZY crap in it this is cheeeeeezy but hey it works and it s portable!!!
11,162
protected boolean prepare ( final Context2D context , final Attributes attr , final double alpha ) { if ( m_list . size ( ) < 1 ) { if ( false == parse ( attr ) ) { return false ; } } if ( m_list . size ( ) < 1 ) { return false ; } context . path ( m_list ) ; return true ; }
Draws this star .
11,163
protected boolean prepare ( final Context2D context , final Attributes attr , final double alpha ) { final double r = attr . getRadius ( ) ; if ( r > 0 ) { context . beginPath ( ) ; context . arc ( 0 , 0 , r , 0 , Math . PI * 2 , true ) ; context . closePath ( ) ; return true ; } return false ; }
Draws this circle
11,164
public Layer getLayer ( ) { final Node < ? > parent = getParent ( ) ; if ( null != parent ) { return parent . getLayer ( ) ; } return null ; }
Returns the Layer that this Node is on .
11,165
public Scene getScene ( ) { final Node < ? > parent = getParent ( ) ; if ( null != parent ) { return parent . getScene ( ) ; } return null ; }
Returns the Scene that this Node is on .
11,166
public Viewport getViewport ( ) { final Node < ? > parent = getParent ( ) ; if ( null != parent ) { return parent . getViewport ( ) ; } return null ; }
Returns the Viewport that this Node is on .
11,167
public static Plugin findPlugin ( List < Plugin > plugins , String artifactId ) { if ( plugins != null ) { for ( Plugin plugin : plugins ) { String groupId = plugin . getGroupId ( ) ; if ( Strings . isNullOrBlank ( groupId ) || Objects . equal ( groupId , mavenPluginsGroupId ) ) { if ( Objects . equal ( artifactId , plugin . getArtifactId ( ) ) ) { return plugin ; } } } } return null ; }
Returns the maven plugin for the given artifact id or returns null if it cannot be found
11,168
public static Profile findProfile ( Model mavenModel , String profileId ) { List < Profile > profiles = mavenModel . getProfiles ( ) ; if ( profiles != null ) { for ( Profile profile : profiles ) { if ( Objects . equal ( profile . getId ( ) , profileId ) ) { return profile ; } } } return null ; }
Returns the profile for the given id or null if it could not be found
11,169
public static boolean ensureMavenDependencyAdded ( Project project , DependencyInstaller dependencyInstaller , String groupId , String artifactId , String scope ) { List < Dependency > dependencies = project . getFacet ( DependencyFacet . class ) . getEffectiveDependencies ( ) ; for ( Dependency d : dependencies ) { if ( groupId . equals ( d . getCoordinate ( ) . getGroupId ( ) ) && artifactId . equals ( d . getCoordinate ( ) . getArtifactId ( ) ) ) { getLOG ( ) . debug ( "Project already includes: " + groupId + ":" + artifactId + " for version: " + d . getCoordinate ( ) . getVersion ( ) ) ; return false ; } } DependencyBuilder component = DependencyBuilder . create ( ) . setGroupId ( groupId ) . setArtifactId ( artifactId ) ; if ( scope != null ) { component . setScopeType ( scope ) ; } String version = MavenHelpers . getVersion ( groupId , artifactId ) ; if ( Strings . isNotBlank ( version ) ) { component = component . setVersion ( version ) ; getLOG ( ) . debug ( "Adding pom.xml dependency: " + groupId + ":" + artifactId + " version: " + version + " scope: " + scope ) ; } else { getLOG ( ) . debug ( "No version could be found for: " + groupId + ":" + artifactId ) ; } dependencyInstaller . install ( project , component ) ; return true ; }
Returns true if the dependency was added or false if its already there
11,170
public static boolean hasDependency ( Model pom , String groupId , String artifactId ) { if ( pom != null ) { List < org . apache . maven . model . Dependency > dependencies = pom . getDependencies ( ) ; return hasDependency ( dependencies , groupId , artifactId ) ; } return false ; }
Returns true if the pom has the given dependency
11,171
public static boolean hasDependency ( List < org . apache . maven . model . Dependency > dependencies , String groupId , String artifactId ) { if ( dependencies != null ) { for ( org . apache . maven . model . Dependency dependency : dependencies ) { if ( Objects . equal ( groupId , dependency . getGroupId ( ) ) && Objects . equal ( artifactId , dependency . getArtifactId ( ) ) ) { return true ; } } } return false ; }
Returns true if the list has the given dependency
11,172
public static boolean hasManagedDependency ( Model pom , String groupId , String artifactId ) { if ( pom != null ) { DependencyManagement dependencyManagement = pom . getDependencyManagement ( ) ; if ( dependencyManagement != null ) { return hasDependency ( dependencyManagement . getDependencies ( ) , groupId , artifactId ) ; } } return false ; }
Returns true if the pom has the given managed dependency
11,173
public static boolean updatePomProperty ( Properties properties , String name , Object value , boolean updated ) { if ( value != null ) { Object oldValue = properties . get ( name ) ; if ( ! Objects . equal ( oldValue , value ) ) { getLOG ( ) . debug ( "Updating pom.xml property: " + name + " to " + value ) ; properties . put ( name , value ) ; return true ; } } return updated ; }
Updates the given maven property value if value is not null and returns true if the pom has been changed
11,174
protected boolean prepare ( final Context2D context , final Attributes attr , final double alpha ) { final double w = attr . getWidth ( ) ; final double h = attr . getHeight ( ) ; if ( ( w > 0 ) && ( h > 0 ) ) { context . beginPath ( ) ; context . ellipse ( 0 , 0 , w / 2 , h / 2 , 0 , 0 , Math . PI * 2 , true ) ; context . closePath ( ) ; return true ; } return false ; }
Draws this ellipse .
11,175
public static Result loadCamelComponentDetails ( CamelCatalog camelCatalog , String camelComponentName , CamelComponentDetails details ) { String json = camelCatalog . componentJSonSchema ( camelComponentName ) ; if ( json == null ) { return Results . fail ( "Could not find catalog entry for component name: " + camelComponentName ) ; } List < Map < String , String > > data = JSonSchemaHelper . parseJsonSchema ( "component" , json , false ) ; for ( Map < String , String > row : data ) { String javaType = row . get ( "javaType" ) ; if ( ! Strings . isNullOrEmpty ( javaType ) ) { details . setComponentClassQName ( javaType ) ; } String groupId = row . get ( "groupId" ) ; if ( ! Strings . isNullOrEmpty ( groupId ) ) { details . setGroupId ( groupId ) ; } String artifactId = row . get ( "artifactId" ) ; if ( ! Strings . isNullOrEmpty ( artifactId ) ) { details . setArtifactId ( artifactId ) ; } String version = row . get ( "version" ) ; if ( ! Strings . isNullOrEmpty ( version ) ) { details . setVersion ( version ) ; } } if ( Strings . isNullOrEmpty ( details . getComponentClassQName ( ) ) ) { return Results . fail ( "Could not find fully qualified class name in catalog for component name: " + camelComponentName ) ; } return null ; }
Populates the details for the given component returning a Result if it fails .
11,176
public static Class < Object > loadValidInputTypes ( String javaType , String type ) { int idx = javaType . indexOf ( '<' ) ; if ( idx > 0 ) { javaType = javaType . substring ( 0 , idx ) ; } try { Class < Object > clazz = getPrimitiveWrapperClassType ( type ) ; if ( clazz == null ) { clazz = loadPrimitiveWrapperType ( javaType ) ; } if ( clazz == null ) { clazz = loadStringSupportedType ( javaType ) ; } if ( clazz == null ) { try { clazz = ( Class < Object > ) Class . forName ( javaType ) ; } catch ( Throwable e ) { if ( "object" . equals ( type ) ) { clazz = loadPrimitiveWrapperType ( "java.lang.String" ) ; } } } if ( clazz != null && ( clazz . equals ( String . class ) || clazz . equals ( Date . class ) || clazz . equals ( Boolean . class ) || clazz . isPrimitive ( ) || Number . class . isAssignableFrom ( clazz ) ) ) { return clazz ; } if ( "object" . equals ( type ) ) { clazz = loadPrimitiveWrapperType ( "java.lang.String" ) ; return clazz ; } } catch ( Throwable e ) { } return null ; }
Converts a java type as a string to a valid input type and returns the class or null if its not supported
11,177
public static Class getPrimitiveWrapperClassType ( String name ) { if ( "string" . equals ( name ) ) { return String . class ; } else if ( "boolean" . equals ( name ) ) { return Boolean . class ; } else if ( "integer" . equals ( name ) ) { return Integer . class ; } else if ( "number" . equals ( name ) ) { return Float . class ; } return null ; }
Gets the JSon schema primitive type .
11,178
public void addValidationError ( String message ) { messages . add ( new UIMessageDTO ( message , null , UIMessage . Severity . ERROR ) ) ; valid = false ; canExecute = false ; }
Adds an extra validation error
11,179
public Object marshalRootElement ( ) { if ( justRoutes ) { RoutesDefinition routes = new RoutesDefinition ( ) ; routes . setRoutes ( contextElement . getRoutes ( ) ) ; return routes ; } else { return contextElement ; } }
Returns the root element to be marshalled as XML
11,180
public Set < String > endpointUris ( ) { try { List < CamelEndpointFactoryBean > endpoints = contextElement . getEndpoints ( ) ; List < String > uris = new LinkedList < String > ( ) ; if ( endpoints != null ) { for ( CamelEndpointFactoryBean cefb : endpoints ) { uris . add ( cefb . getUri ( ) ) ; } } List < Node > sessions = nodesByNamespace ( doc , droolsNamespace . getURI ( ) , "ksession" ) ; if ( sessions != null ) { for ( Node session : sessions ) { if ( session instanceof Element ) { Element e = ( Element ) session ; String node = e . getAttributeValue ( "node" ) ; String sid = e . getAttributeValue ( "id" ) ; if ( node != null && node . length ( ) > 0 && sid != null && sid . length ( ) > 0 ) { String du = "drools:" + node + "/" + sid ; boolean exists = false ; for ( String uri : uris ) { if ( uri . startsWith ( du ) ) { exists = true ; } } if ( ! exists ) { uris . add ( du ) ; } } } } } return new TreeSet < String > ( uris ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; return new HashSet < String > ( ) ; } }
Returns the endpoint URIs used in the context
11,181
protected boolean isValidCommandName ( String name ) { if ( Strings . isNullOrBlank ( name ) || ignoreCommands . contains ( name ) ) { return false ; } for ( String prefix : ignoreCommandPrefixes ) { if ( name . startsWith ( prefix ) ) { return false ; } } return true ; }
Returns true if the name is valid . Lets filter out commands which are not suitable to run inside fabric8 - forge
11,182
public static String mandatoryAttributeValue ( Map < Object , Object > attributeMap , String name ) { Object value = attributeMap . get ( name ) ; if ( value != null ) { String text = value . toString ( ) ; if ( ! Strings . isBlank ( text ) ) { return text ; } } throw new IllegalArgumentException ( "The attribute value '" + name + "' did not get passed on from the previous wizard page" ) ; }
Returns the mandatory String value of the given name
11,183
public void validateFileDoesNotExist ( UIInput < String > directory , UIInput < String > fileName , UIValidationContext validator ) { String resourcePath = CamelXmlHelper . createFileName ( directory , fileName ) ; if ( files . contains ( resourcePath ) ) { validator . addValidationError ( fileName , "A file with that name already exists!" ) ; } }
Validates that the given selected directory and fileName are valid and that the file doesn t already exist
11,184
protected boolean prepare ( final Context2D context , final Attributes attr , final double alpha ) { final double r = attr . getRadius ( ) ; final double beg = attr . getStartAngle ( ) ; final double end = attr . getEndAngle ( ) ; if ( r > 0 ) { context . beginPath ( ) ; if ( beg == end ) { context . arc ( 0 , 0 , r , 0 , Math . PI * 2 , true ) ; } else { context . arc ( 0 , 0 , r , beg , end , attr . isCounterClockwise ( ) ) ; } context . closePath ( ) ; return true ; } return false ; }
Draws this chord .
11,185
private void writeToNetwork ( EngineConnection engineConnection ) { final String methodName = "writeToNetwork" ; logger . entry ( this , methodName , engineConnection ) ; if ( engineConnection . transport . pending ( ) > 0 ) { ByteBuffer head = engineConnection . transport . head ( ) ; int amount = head . remaining ( ) ; engineConnection . channel . write ( head , new NetworkWritePromiseImpl ( this , amount , engineConnection ) ) ; engineConnection . transport . pop ( amount ) ; engineConnection . transport . tick ( System . currentTimeMillis ( ) ) ; } logger . exit ( this , methodName ) ; }
Drains any pending data from a Proton transport object onto the network
11,186
private void resetReceiveIdleTimer ( Event event ) { final String methodName = "resetReceiveIdleTimer" ; logger . entry ( this , methodName , event ) ; if ( receiveScheduledFuture != null ) { receiveScheduledFuture . cancel ( false ) ; } final Transport transport = event . getTransport ( ) ; if ( transport != null ) { final int localIdleTimeOut = transport . getIdleTimeout ( ) ; if ( localIdleTimeOut > 0 ) { Runnable receiveTimeout = new Runnable ( ) { public void run ( ) { final String methodName = "run" ; logger . entry ( this , methodName ) ; transport . process ( ) ; transport . tick ( System . currentTimeMillis ( ) ) ; logger . exit ( methodName ) ; } } ; receiveScheduledFuture = scheduler . schedule ( receiveTimeout , localIdleTimeOut , TimeUnit . MILLISECONDS ) ; } } logger . exit ( this , methodName ) ; }
Reset the local idle timers now that we have received some data .
11,187
private WiresMagnet getCloserMagnet ( final WiresShape shape , final WiresContainer parent , final boolean allowOverlap ) { final WiresShape parentShape = ( WiresShape ) parent ; final MagnetManager . Magnets magnets = parentShape . getMagnets ( ) ; final Point2D shapeLocation = shape . getComputedLocation ( ) ; final Point2D shapeCenter = Geometry . findCenter ( shape . getPath ( ) . getBoundingBox ( ) ) ; final double shapeX = shapeCenter . getX ( ) + shapeLocation . getX ( ) ; final double shapeY = shapeCenter . getX ( ) + shapeLocation . getY ( ) ; int magnetIndex = - 1 ; Double minDistance = null ; for ( int i = 1 ; i < magnets . size ( ) ; i ++ ) { final WiresMagnet magnet = magnets . getMagnet ( i ) ; if ( allowOverlap || ! hasShapeOnMagnet ( magnet , parentShape ) ) { final double magnetX = magnet . getControl ( ) . getLocation ( ) . getX ( ) ; final double magnetY = magnet . getControl ( ) . getLocation ( ) . getY ( ) ; final double distance = Geometry . distance ( magnetX , magnetY , shapeX , shapeY ) ; if ( ( minDistance == null ) || ( distance < minDistance ) ) { minDistance = distance ; magnetIndex = i ; } } } return ( magnetIndex > 0 ? magnets . getMagnet ( magnetIndex ) : null ) ; }
Reurn the closer magnet
11,188
public static void stop ( ) { final ILoggerFactory loggerFactory = org . slf4j . LoggerFactory . getILoggerFactory ( ) ; if ( loggerFactory instanceof LoggerContext ) { final LoggerContext context = ( LoggerContext ) loggerFactory ; context . stop ( ) ; } setup . getAndSet ( false ) ; }
Stops the logging .
11,189
public void move ( final double dx , final double dy , final boolean midPointsOnly , final boolean moveLinePoints ) { final IControlHandleList handles = m_connector . getPointHandles ( ) ; int start = 0 ; int end = handles . size ( ) ; if ( midPointsOnly ) { if ( m_connector . getHeadConnection ( ) . getMagnet ( ) != null ) { start ++ ; } if ( m_connector . getTailConnection ( ) . getMagnet ( ) != null ) { end -- ; } } final Point2DArray points = m_connector . getLine ( ) . getPoint2DArray ( ) ; for ( int i = start , j = ( start == 0 ) ? start : 2 ; i < end ; i ++ , j += 2 ) { if ( moveLinePoints ) { final Point2D p = points . get ( i ) ; p . setX ( m_startPoints . get ( j ) + dx ) ; p . setY ( m_startPoints . get ( j + 1 ) + dy ) ; } final IControlHandle h = handles . getHandle ( i ) ; final IPrimitive < ? > prim = h . getControl ( ) ; prim . setX ( m_startPoints . get ( j ) + dx ) ; prim . setY ( m_startPoints . get ( j + 1 ) + dy ) ; } if ( moveLinePoints ) { m_connector . getLine ( ) . refresh ( ) ; } m_wiresManager . getLayer ( ) . getLayer ( ) . batch ( ) ; }
See class javadocs to explain why we have these booleans
11,190
public static String getVersion ( ) { String version = "unknown" ; final URLClassLoader cl = ( URLClassLoader ) cclass . getClassLoader ( ) ; try { final URL url = cl . findResource ( "META-INF/MANIFEST.MF" ) ; final Manifest manifest = new Manifest ( url . openStream ( ) ) ; for ( Entry < Object , Object > entry : manifest . getMainAttributes ( ) . entrySet ( ) ) { final Attributes . Name key = ( Attributes . Name ) entry . getKey ( ) ; if ( Attributes . Name . IMPLEMENTATION_VERSION . equals ( key ) ) { version = ( String ) entry . getValue ( ) ; } } } catch ( IOException e ) { logger . error ( "Unable to determine the product version due to error" , e ) ; } return version ; }
obtains the MQ Light version information from the manifest .
11,191
public static String after ( String text , String after ) { if ( ! text . contains ( after ) ) { return null ; } return text . substring ( text . indexOf ( after ) + after . length ( ) ) ; }
Returns the string after the given token
11,192
public static String before ( String text , String before ) { if ( ! text . contains ( before ) ) { return null ; } return text . substring ( 0 , text . indexOf ( before ) ) ; }
Returns the string before the given token
11,193
public static String between ( String text , String after , String before ) { text = after ( text , after ) ; if ( text == null ) { return null ; } return before ( text , before ) ; }
Returns the string between the given tokens
11,194
public static List < InputComponent > addInputComponents ( UIBuilder builder , InputComponent ... components ) { List < InputComponent > inputComponents = new ArrayList < > ( ) ; for ( InputComponent component : components ) { builder . add ( component ) ; inputComponents . add ( component ) ; } return inputComponents ; }
A helper function to add the components to the builder and return a list of all the components
11,195
public static < T > void setInitialComponentValue ( UIInput < T > inputComponent , T value ) { if ( value != null ) { inputComponent . setValue ( value ) ; } }
If the initial value is not blank lets set the value on the underlying component
11,196
public static String createCommitMessage ( String name , ExecutionRequest executionRequest ) { StringBuilder builder = new StringBuilder ( name ) ; List < Map < String , Object > > inputList = executionRequest . getInputList ( ) ; for ( Map < String , Object > map : inputList ) { Set < Map . Entry < String , Object > > entries = map . entrySet ( ) ; for ( Map . Entry < String , Object > entry : entries ) { String key = entry . getKey ( ) ; String textValue = null ; Object value = entry . getValue ( ) ; if ( value != null ) { textValue = value . toString ( ) ; } if ( ! Strings . isNullOrEmpty ( textValue ) && ! textValue . equals ( "0" ) && ! textValue . toLowerCase ( ) . equals ( "false" ) ) { builder . append ( " --" ) ; builder . append ( key ) ; builder . append ( "=" ) ; builder . append ( textValue ) ; } } } return builder . toString ( ) ; }
Lets generate a commit message with the command name and all the parameters we specify
11,197
public static ObjectMapper createObjectMapper ( ) { ObjectMapper mapper = new ObjectMapper ( ) ; mapper . enable ( SerializationFeature . INDENT_OUTPUT ) ; return mapper ; }
Creates a configured Jackson object mapper for parsing JSON
11,198
public static String asTitleCase ( String text ) { StringBuilder sb = new StringBuilder ( ) ; boolean next = true ; for ( char c : text . toCharArray ( ) ) { if ( Character . isSpaceChar ( c ) ) { next = true ; } else if ( next ) { c = Character . toTitleCase ( c ) ; next = false ; } sb . append ( c ) ; } return sb . toString ( ) ; }
Returns the text in title case
11,199
public static boolean isDefaultValue ( CamelCatalog camelCatalog , String scheme , String key , String value ) { String json = camelCatalog . componentJSonSchema ( scheme ) ; if ( json == null ) { throw new IllegalArgumentException ( "Could not find catalog entry for component name: " + scheme ) ; } List < Map < String , String > > data = JSonSchemaHelper . parseJsonSchema ( "properties" , json , true ) ; if ( data != null ) { for ( Map < String , String > propertyMap : data ) { String name = propertyMap . get ( "name" ) ; String defaultValue = propertyMap . get ( "defaultValue" ) ; if ( key . equals ( name ) ) { return value . equalsIgnoreCase ( defaultValue ) ; } } } return false ; }
Checks whether the given value is matching the default value from the given component .