wro4j-extensions/src/main/java/ro/isdc/wro/extensions/model/factory/JsonModelFactory.java
@Override
  public synchronized WroModel create() {
    final StopWatch stopWatch = new StopWatch("Create Wro Model from Groovy");
    try {
      stopWatch.start("createModel");
      final Type type = new TypeToken<WroModel>() {}.getType();
      final InputStream is = getModelResourceAsStream();
      if (is == null) {
        throw new WroRuntimeException("Invalid model stream provided!");
      }
      final WroModel model = new Gson().fromJson(new InputStreamReader(new AutoCloseInputStream(is)), type);
      LOG.debug("json model: {}", model);
      if (model == null) {
        throw new WroRuntimeException("Invalid content provided, cannot build model!");
      }
      return model;
    } catch (final Exception e) {
      throw new WroRuntimeException("Invalid model found!", e);
    } finally {
      stopWatch.stop();
      LOG.debug(stopWatch.prettyPrint());
    }
  }
@Override
  public synchronized WroModel create() {
    final StopWatch stopWatch = new StopWatch("Create Wro Model from Groovy");
    try {
      stopWatch.start("createModel");
      final Type type = new TypeToken<WroModel>() {}.getType();
      final InputStream is = getModelResourceAsStream();
      if (is == null) {
        throw new WroRuntimeException("Invalid model stream provided!");
      }
      final WroModel model = new Gson().fromJson(new InputStreamReader(new AutoCloseInputStream(is)), type);
      LOG.debug("json model: {}", model);
      if (model == null) {
        throw new WroRuntimeException("Invalid content provided, cannot build model!");
      }
      return model;
    } catch (final Exception e) {
      throw new WroRuntimeException("Invalid model found!", e);
    } finally {
      stopWatch.stop();
      LOG.debug(stopWatch.prettyPrint());
    }
  }
@ Override public synchronized WroModel create ( ) { final StopWatch stopWatch = new StopWatch ( "Create Wro Model from Groovy" ) ; try { stopWatch . start ( "createModel" ) ; final Type type = new TypeToken < WroModel > ( ) { } . getType ( ) ; final InputStream is = getModelResourceAsStream ( ) ; if ( is == null ) { throw new WroRuntimeException ( "Invalid model stream provided!" ) ; } final WroModel model = new Gson ( ) . fromJson ( new InputStreamReader ( new AutoCloseInputStream ( is ) ) , type ) ; LOG . debug ( "json model: {}" , model ) ; if ( model == null ) { throw new WroRuntimeException ( "Invalid content provided, cannot build model!" ) ; } return model ; } catch ( final Exception e ) { throw new WroRuntimeException ( "Invalid model found!" , e ) ; } finally { stopWatch . stop ( ) ; LOG . debug ( stopWatch . prettyPrint ( ) ) ; } }
{@inheritDoc}
{