當前位置: 首頁>>代碼示例>>Java>>正文


Java Long類代碼示例

本文整理匯總了Java中java.lang.Long的典型用法代碼示例。如果您正苦於以下問題:Java Long類的具體用法?Java Long怎麽用?Java Long使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Long類屬於java.lang包,在下文中一共展示了Long類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: should_test_observable_interval

import java.lang.Long; //導入依賴的package包/類
@Test
public void should_test_observable_interval() {
    TestScheduler scheduler = new TestScheduler();
    final List<Long> result = new ArrayList<>();
    Observable.interval(1, TimeUnit.SECONDS, scheduler)
            .take(5)
            .subscribe(new Action1<Long>() {
                @Override
                public void call(Long aLong) {
                    result.add(aLong);
                }
            });
    assertTrue(result.isEmpty());
    scheduler.advanceTimeBy(2, TimeUnit.SECONDS);
    assertEquals(2, result.size());
    scheduler.advanceTimeBy(10, TimeUnit.SECONDS);
    assertEquals(5, result.size());
}
 
開發者ID:colintheshots,項目名稱:AnDevCon-RxPatterns,代碼行數:19,代碼來源:Example16Test.java

示例2: isDue

import java.lang.Long; //導入依賴的package包/類
/**
 * 判斷緩存的byte數據是否到期
 *
 * @param data
 * @return true:到期了 false:還沒有到期
 */
private static boolean isDue(byte[] data) {
    String[] strs = getDateInfoFromDate(data);
    if (strs != null && strs.length == 2) {
        String saveTimeStr = strs[0];
        while (saveTimeStr.startsWith("0")) {
            saveTimeStr = saveTimeStr.substring(1, saveTimeStr.length());
        }
        long saveTime = Long.parseLong(saveTimeStr);
        long deleteAfter = Long.parseLong(strs[1]);
        if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) {
            return true;
        }
    }
    return false;
}
 
開發者ID:YiuChoi,項目名稱:MicroReader,代碼行數:22,代碼來源:CacheUtil.java

示例3: BgReadingMessage

import java.lang.Long; //導入依賴的package包/類
public BgReadingMessage(Long timestamp, Double time_since_sensor_started, Double raw_data, Double filtered_data, Double age_adjusted_raw_value, Boolean calibration_flag, Double calculated_value, Double filtered_calculated_value, Double calculated_value_slope, Double a, Double b, Double c, Double ra, Double rb, Double rc, String uuid, String calibration_uuid, String sensor_uuid, Boolean ignoreforstats, Double raw_calculated, Boolean hide_slope, String noise, ByteString unknownFields) {
  super(ADAPTER, unknownFields);
  this.timestamp = timestamp;
  this.time_since_sensor_started = time_since_sensor_started;
  this.raw_data = raw_data;
  this.filtered_data = filtered_data;
  this.age_adjusted_raw_value = age_adjusted_raw_value;
  this.calibration_flag = calibration_flag;
  this.calculated_value = calculated_value;
  this.filtered_calculated_value = filtered_calculated_value;
  this.calculated_value_slope = calculated_value_slope;
  this.a = a;
  this.b = b;
  this.c = c;
  this.ra = ra;
  this.rb = rb;
  this.rc = rc;
  this.uuid = uuid;
  this.calibration_uuid = calibration_uuid;
  this.sensor_uuid = sensor_uuid;
  this.ignoreforstats = ignoreforstats;
  this.raw_calculated = raw_calculated;
  this.hide_slope = hide_slope;
  this.noise = noise;
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:26,代碼來源:BgReadingMessage.java

示例4: ReviewInput

import java.lang.Long; //導入依賴的package包/類
ReviewInput(long stars, Input<Long> nullableIntFieldWithDefaultValue, Input<String> commentary,
    @Nonnull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue,
    Input<Episode> nullableEnum, Input<List<Object>> listOfCustomScalar,
    Input<Object> customScalar, Input<List<Episode>> listOfEnums, Input<List<Long>> listOfInt,
    Input<List<String>> listOfString, Input<Boolean> booleanWithDefaultValue) {
  this.stars = stars;
  this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue;
  this.commentary = commentary;
  this.favoriteColor = favoriteColor;
  this.enumWithDefaultValue = enumWithDefaultValue;
  this.nullableEnum = nullableEnum;
  this.listOfCustomScalar = listOfCustomScalar;
  this.customScalar = customScalar;
  this.listOfEnums = listOfEnums;
  this.listOfInt = listOfInt;
  this.listOfString = listOfString;
  this.booleanWithDefaultValue = booleanWithDefaultValue;
}
 
開發者ID:apollographql,項目名稱:apollo-android,代碼行數:19,代碼來源:ReviewInput.java

示例5: ReviewInput

import java.lang.Long; //導入依賴的package包/類
ReviewInput(long stars, Input<Long> nullableIntFieldWithDefaultValue, Input<String> commentary,
    @Nonnull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue,
    Input<Episode> nullableEnum, Input<List<Date>> listOfCustomScalar, Input<Date> customScalar,
    Input<List<Episode>> listOfEnums, Input<List<Long>> listOfInt,
    Input<List<String>> listOfString, Input<Boolean> booleanWithDefaultValue) {
  this.stars = stars;
  this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue;
  this.commentary = commentary;
  this.favoriteColor = favoriteColor;
  this.enumWithDefaultValue = enumWithDefaultValue;
  this.nullableEnum = nullableEnum;
  this.listOfCustomScalar = listOfCustomScalar;
  this.customScalar = customScalar;
  this.listOfEnums = listOfEnums;
  this.listOfInt = listOfInt;
  this.listOfString = listOfString;
  this.booleanWithDefaultValue = booleanWithDefaultValue;
}
 
開發者ID:apollographql,項目名稱:apollo-android,代碼行數:19,代碼來源:ReviewInput.java

示例6: Data

import java.lang.Long; //導入依賴的package包/類
public Data(@Nullable String graphQlString, @Nullable String graphQlIdNullable,
    @Nonnull String graphQlIdNonNullable, @Nullable Long graphQlIntNullable,
    long graphQlIntNonNullable, @Nullable Double graphQlFloatNullable,
    double graphQlFloatNonNullable, @Nullable Boolean graphQlBooleanNullable,
    boolean graphQlBooleanNonNullable, @Nullable List<Long> graphQlListOfInt,
    @Nullable List<GraphQlListOfObject> graphQlListOfObjects) {
  this.graphQlString = Optional.fromNullable(graphQlString);
  this.graphQlIdNullable = Optional.fromNullable(graphQlIdNullable);
  this.graphQlIdNonNullable = Utils.checkNotNull(graphQlIdNonNullable, "graphQlIdNonNullable == null");
  this.graphQlIntNullable = Optional.fromNullable(graphQlIntNullable);
  this.graphQlIntNonNullable = graphQlIntNonNullable;
  this.graphQlFloatNullable = Optional.fromNullable(graphQlFloatNullable);
  this.graphQlFloatNonNullable = graphQlFloatNonNullable;
  this.graphQlBooleanNullable = Optional.fromNullable(graphQlBooleanNullable);
  this.graphQlBooleanNonNullable = graphQlBooleanNonNullable;
  this.graphQlListOfInt = Optional.fromNullable(graphQlListOfInt);
  this.graphQlListOfObjects = Optional.fromNullable(graphQlListOfObjects);
}
 
開發者ID:apollographql,項目名稱:apollo-android,代碼行數:19,代碼來源:TestQuery.java

示例7: onTransact

import java.lang.Long; //導入依賴的package包/類
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
    switch(code) {
        case TRANSACT_methodWithLongParameter: {
            data.enforceInterface(this.getInterfaceDescriptor());

            final Long longParameterTmp;
            if (data.readByte() == -1) {
                longParameterTmp = null;
            } else {
                longParameterTmp = data.readLong();
            }

            delegate.methodWithLongParameter(longParameterTmp);
            reply.writeNoException();

            return true;
        }
    }
    return super.onTransact(code, data, reply, flags);
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:22,代碼來源:LongTest$$AidlServerImpl.java

示例8: methodWithLongParameter

import java.lang.Long; //導入依賴的package包/類
@Override
public void methodWithLongParameter(Long longParameter) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(LongTest$$AidlServerImpl.DESCRIPTOR);

        if (longParameter == null) {
            data.writeByte((byte) -1);
        } else {
            data.writeByte((byte) 0);
            data.writeLong(longParameter);
        }

        delegate.transact(LongTest$$AidlServerImpl.TRANSACT_methodWithLongParameter, data, reply, 0);
        reply.readException();
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:22,代碼來源:LongTest$$AidlClientImpl.java

示例9: findById

import java.lang.Long; //導入依賴的package包/類
/**
 * Performs a query for a trinityprocessortest.full.MyEntity with given id.
 * If no such instance is found, null is returned.
 *
 * @param id The id of the instance to find.
 * @return The trinityprocessortest.full.MyEntity with given id, or null if it doesn't exist. */
@Override
public MyEntity findById(final Long id) {
  if (id == null) {
    return null;
  }

  MyEntity result = null;

  Cursor cursor = mDatabase.query("entities", null, "id=?", new String[] {String.valueOf(id)}, null, null, null, "1");
  try {
    if (cursor.moveToFirst()) {
      result = read(cursor);
    }
  } finally{
    cursor.close();
  }

  return result;
}
 
開發者ID:nhaarman,項目名稱:trinity,代碼行數:26,代碼來源:TrinityMyRepository.java

示例10: changeKeyComboCode

import java.lang.Long; //導入依賴的package包/類
@Test
public void changeKeyComboCode() {
    String keyNavigateNext = mContext.getString(R.string.keycombo_shortcut_navigate_next);

    // Check default key combo code.
    long defaultKeyComboCode = mDefaultKeyComboModel.getDefaultKeyComboCode(keyNavigateNext);
    assertEquals(defaultKeyComboCode,
            mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));

    // Change key combo code.
    long newKeyComboCode = KeyComboManager.getKeyComboCode(
            KeyComboModel.NO_MODIFIER, KeyEvent.KEYCODE_X);
    mDefaultKeyComboModel.saveKeyComboCode(keyNavigateNext, newKeyComboCode);

    Map<String, Long> keyComboCodeMap = mDefaultKeyComboModel.getKeyComboCodeMap();
    assertEquals(newKeyComboCode, keyComboCodeMap.get(keyNavigateNext).longValue());
    assertEquals(newKeyComboCode, mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));

    assertEquals(newKeyComboCode, mPref.getLong(PREF_KEY_PREFIX + keyNavigateNext, -1));

    // Create new DefaultKeyComboModel model and confirm it's loaded.
    DefaultKeyComboModel newDefaultKeyComboModel = new DefaultKeyComboModel(mContext);
    assertEquals(newKeyComboCode,
            newDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));
}
 
開發者ID:google,項目名稱:talkback,代碼行數:26,代碼來源:DefaultKeyComboModelTest.java

示例11: clearKeyComboCode

import java.lang.Long; //導入依賴的package包/類
@Test
public void clearKeyComboCode() {
    String keyNavigateNext = mContext.getString(R.string.keycombo_shortcut_navigate_next);

    // Check default key combo code.
    long defaultKeyComboCode = mDefaultKeyComboModel.getDefaultKeyComboCode(keyNavigateNext);
    assertEquals(defaultKeyComboCode,
            mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));

    // Clear key combo code.
    mDefaultKeyComboModel.clearKeyComboCode(keyNavigateNext);

    Map<String, Long> keyComboCodeMap = mDefaultKeyComboModel.getKeyComboCodeMap();
    assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED,
            keyComboCodeMap.get(keyNavigateNext).longValue());
    assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED,
            mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));

    assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED,
            mPref.getLong(PREF_KEY_PREFIX + keyNavigateNext, -1));

    // Create new DefaultKeyComboModel and confirm it's loaded.
    DefaultKeyComboModel newDefaultKeyComboModel = new DefaultKeyComboModel(mContext);
    assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED,
            newDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext));
}
 
開發者ID:google,項目名稱:talkback,代碼行數:27,代碼來源:DefaultKeyComboModelTest.java

示例12: testFloatNarrowing

import java.lang.Long; //導入依賴的package包/類
public void testFloatNarrowing() {
  float fmin = Float.NEGATIVE_INFINITY;
  float fmax = Float.POSITIVE_INFINITY;
  assertEquals("fmin as long failed", Long.MIN_VALUE, (long) fmin);
  assertEquals("fmax as long failed", Long.MAX_VALUE, (long) fmax);
  assertEquals("fmin as int failed", Integer.MIN_VALUE, (int) fmin);
  assertEquals("fmax as int failed", Integer.MAX_VALUE, (int) fmax);
  assertEquals("fmin as char failed", Character.MIN_VALUE, (char) fmin);
  assertEquals("fmax as char failed", Character.MAX_VALUE, (char) fmax);

  // Surprising values for shorts and bytes, but that's what's specified.
  assertEquals("fmin as short failed", 0, (short) fmin);
  assertEquals("fmax as short failed", -1, (short) fmax);
  assertEquals("fmin as byte failed", 0, (byte) fmin);
  assertEquals("fmax as byte failed", -1, (byte) fmax);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:17,代碼來源:MaxFloatingPointTest.java

示例13: updateGM

import java.lang.Long; //導入依賴的package包/類
void updateGM( long value, String name )
{
  mApp.mDData.updateGMName( mCIDid, mApp.mCID, name );
  String id = Long.toString(mCIDid);
  // CalibCBlock blk = mApp.mDData.selectGM( mCIDid, mApp.mCID );
  mSaveCBlock.setGroup( value );

  // if ( mApp.mListRefresh ) {
  //   mDataAdapter.notifyDataSetChanged();
  // } else {
    mSaveTextView.setText( id + " <" + name + "> " + mSaveData );
    mSaveTextView.setTextColor( mSaveCBlock.color() );
    // mSaveTextView.invalidate();
    // updateDisplay( ); // FIXME
  // }
}
 
開發者ID:marcocorvi,項目名稱:topodroid,代碼行數:17,代碼來源:GMActivity.java

示例14: equals

import java.lang.Long; //導入依賴的package包/類
@Override
public boolean equals(Object obj) {
    if (obj instanceof TimeDuration) {
        return milisecond == ((TimeDuration) obj).getMilisecond();
    }
    if (obj instanceof Integer) {
        return milisecond == ((Integer) obj).intValue();
    }
    if (obj instanceof java.lang.Long) {
        return milisecond == ((Long) obj).longValue();
    }
    if (obj instanceof Int) {
        return milisecond == ((Int) obj).getValue();
    }
    return false;
}
 
開發者ID:mySingleLive,項目名稱:soya,代碼行數:17,代碼來源:TimeDuration.java

示例15: HarvestWatcher

import java.lang.Long; //導入依賴的package包/類
public HarvestWatcher(Context _context){
    Log.d("HarvestWatcher", "created");

    journal = new HarvestJournal(_context);
    reporter = new HarvestReporter(_context);
    handler =  new Handler();
    context = _context;

    // discard initial values because we can not make any
    // assumptions regarding whether or not these values
    // were accounted before. Only measure traffic since
    // the service started.
    HarvestTrafficStats stats = new HarvestTrafficStats();
    Long initialRx = stats.getTotalRxBytes();
    Long initialTx = stats.getTotalTxBytes();
    trafficJournal = new HarvestTrafficJournal(_context, initialRx, initialTx);
}
 
開發者ID:tchx84,項目名稱:analytics-client,代碼行數:18,代碼來源:HarvestWatcher.java


注:本文中的java.lang.Long類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。