All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.platform.generate.BridgeHolder Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.platform.generate;

import java.util.concurrent.Callable;

import org.snapscript.core.platform.Bridge;

public class BridgeHolder {

   private volatile Callable source;
   private volatile Bridge value;
   
   public BridgeHolder(Callable source) {
      this.source = source;
   }
   
   public Bridge getBridge() {
      if(value == null) {
         try {
            value = source.call();
         }catch(Exception e) {
            throw new IllegalStateException("Could not create instance", e);
         }
      }
      return value;
   }
   
   public void setBridge(Bridge value) {
      this.value = value;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy