public static Predicate < RegisteredService > getRegisteredServiceExpirationPolicyPredicate ( ) { return service -> { try { if ( service == null ) { return false ; } val policy = service . getExpirationPolicy ( ) ; if ( policy == null || StringUtils . isBlank ( policy . getExpirationDate ( ) ) ) { return true ; } val now = getCurrentSystemTime ( ) ; val expirationDate = DateTimeUtils . localDateTimeOf ( policy . getExpirationDate ( ) ) ; LOGGER . debug ( "Service expiration date is [{}] while now is [{}]" , expirationDate , now ) ; return ! now . isAfter ( expirationDate ) ; } catch ( final Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } return false ; } ; }
Returns a predicate that determined whether a service has expired .