Package jodd.mutable

Examples of jodd.mutable.MutableLong


   * Returns next ID for given entity type.
   * On the first call, it finds the max value of all IDs and stores it.
   * On later calls, stored id is incremented and returned.
   */
  public synchronized long nextId(Class entityType) {
    MutableLong lastId = entityIdsMap.get(entityType);
    if (lastId == null) {
      DbOomManager dbOomManager = DbOomManager.getInstance();

      DbEntityDescriptor ded = dbOomManager.lookupType(entityType);
      String tableName = ded.getTableName();
      String idColumn = ded.getIdColumnName();

      DbOomQuery dbOomQuery = query("select max(" + idColumn + ") from " + tableName);

      long lastLong = dbOomQuery.autoClose().executeCount();

      if (log.isDebugEnabled()) {
        log.debug("Last id for " + entityType.getName() + " is " + lastLong);
      }

      lastId = new MutableLong(lastLong);

      entityIdsMap.put(entityType, lastId);
    }

    lastId.value++;
View Full Code Here


      for (File file : filesArray) {
        if (!acceptFile(file)) {
          continue;
        }

        map.put(file, new MutableLong(file.lastModified()));
      }
    }
  }
View Full Code Here

      for (File file : filesArray) {
        if (!acceptFile(file)) {
          continue;
        }

        MutableLong currentTime = map.get(file);

        if (deletedFiles != null) {
          deletedFiles.remove(file);
        }

        long lastModified = file.lastModified();

        if (currentTime == null) {
          // new file
          map.put(file, new MutableLong(lastModified));
          onChange(file, Event.CREATED);
        }
        else if (currentTime.longValue() != lastModified) {
          // modified file
          currentTime.setValue(lastModified);
          onChange(file, Event.MODIFIED);
        }
      }

      // check for deleted files
View Full Code Here

    if (value.getClass() == MutableLong.class) {
      return (MutableLong) value;
    }

    return new MutableLong(typeConverter.convert(value));
  }
View Full Code Here

  public void testConversion() {
    MutableLongConverter mutableLongConverter = (MutableLongConverter) TypeConverterManager.lookup(MutableLong.class);

    assertNull(mutableLongConverter.convert(null));

    assertEquals(new MutableLong(173), mutableLongConverter.convert(new MutableLong(173)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(Integer.valueOf(173)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(Long.valueOf(173)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(Short.valueOf((short) 173)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(Double.valueOf(173.0D)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(Float.valueOf(173.0F)));
    assertEquals(new MutableLong(173), mutableLongConverter.convert("173"));
    assertEquals(new MutableLong(173), mutableLongConverter.convert(" 173 "));

    try {
      mutableLongConverter.convert("a");
      fail();
    } catch (TypeConversionException ignore) {
View Full Code Here

TOP

Related Classes of jodd.mutable.MutableLong

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.