ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/el/stream/Optional.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/el/stream/Optional.java
Status
scanned
Type
file
Name
Optional.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2273 (2.2 KB)
MD5
317457e3f169b73df6f8902273dcd167
SHA1
9678ea55078c4e91bb6b9597c60fdf48476ff647
SHA256
a9313a59e553163ca3b53b8ed2470562236d1942a26cb8994a965f95d33a544f
SHA512

      
    
SHA1_git
122b77ff89478c98653d96deb6ee76eac2000c47
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Optional.java | 2.2 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.el.stream; import jakarta.el.ELException; import jakarta.el.LambdaExpression; import org.apache.el.util.MessageFactory; public class Optional { private final Object obj; static final Optional EMPTY = new Optional(null); Optional(Object obj) { this.obj = obj; } public Object get() throws ELException { if (obj == null) { throw new ELException(MessageFactory.get("stream.optional.empty")); } else { return obj; } } public void ifPresent(LambdaExpression le) { if (obj != null) { le.invoke(obj); } } public Object orElse(Object other) { if (obj == null) { return other; } else { return obj; } } public Object orElseGet(Object le) { if (obj == null) { // EL 3.0 specification says parameter is LambdaExpression but it // may already have been evaluated. If that is the case, the // original parameter will have been checked to ensure it was a // LambdaExpression before it was evaluated. if (le instanceof LambdaExpression) { return ((LambdaExpression) le).invoke((Object[]) null); } else { return le; } } else { return obj; } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
46.85
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9