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


Java Nonnegative類代碼示例

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


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

示例1: updateCurrentTerm

import javax.annotation.Nonnegative; //導入依賴的package包/類
public void updateCurrentTerm(@Nonnegative long term) {

        checkArgument(term >= 0);

        MDC.put("term", Long.toString(term));
        LOGGER.debug("New term {}", term);

        setCurrentTerm(term);

        try {
            LogProto.JournalEntry entry = LogProto.JournalEntry.newBuilder().setTerm(LogProto.Term.newBuilder().setTerm(term)).build();
            journal.write(entry.toByteArray(), WriteType.SYNC);
        } catch (IOException e) {
            Throwables.propagate(e);
        }
    }
 
開發者ID:lemonJun,項目名稱:TakinRPC,代碼行數:17,代碼來源:DefaultRaftLog.java

示例2: getTeacher

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * @param teacher_id   Integer
 * @param teacher_name String
 * @return Teacher
 * @throws NullObjectException if connect database fail or not found teacher
 */
public Teacher getTeacher(@Nonnegative Integer teacher_id, String teacher_name) throws NullObjectException {
    SQLiteDatabase db;
    try {
        db = this.getReadableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "getTeacher error: " + e.toString());
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.CONNECT_FAIL));
    }

    String query;
    if (teacher_id != null) {
        query = "SELECT * FROM " + TABLE_TEACHER + " WHERE " + Teacher_ID + " = " + teacher_id;
    } else if (teacher_name != null) {
        query = "SELECT * FROM " + TABLE_TEACHER + " WHERE " + Teacher_Name + " = " + "'" + teacher_name + "'";
    } else {
        Log.d(TAG, "getTeacher error: Not found teacher");
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.NOT_FOUND_TEACHER));
    }
    return getTeacherByQuery(query, db);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:27,代碼來源:DBHelper.java

示例3: deleteTeacher

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * Delete a teacher
 *
 * @param teacher_id id of teacher
 * @return DATABASE_CODE
 */
public DATABASE_CODE deleteTeacher(@Nonnegative int teacher_id) {
    SQLiteDatabase db;
    try {
        db = this.getWritableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "deleteTeacher error: " + e.toString());
        return DATABASE_CODE.CONNECT_FAIL;
    }

    String whereClause = Teacher_ID + " = " + teacher_id;

    if (db.delete(TABLE_TEACHER, whereClause, null) != 0) {
        Log.d(TAG, "deleteTeacher success");
        return DATABASE_CODE.DELETE_TEACHER_SUCCESS;
    }
    Log.d(TAG, "deleteTeacher error");
    return DATABASE_CODE.DELETE_TEACHER_FAIL;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:25,代碼來源:DBHelper.java

示例4: getSubject

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * @param subject_id   Integer
 * @param subject_name String
 * @return Subject
 * @throws NullObjectException if connect to database fail or not found subject
 */
public Subject getSubject(@Nonnegative @Nullable Integer subject_id, @Nullable String subject_name) throws NullObjectException {
    SQLiteDatabase db;
    try {
        db = this.getReadableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "getSubject error:" + e.toString());
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.CONNECT_FAIL));
    }

    String query;
    if (subject_id != null) {
        query = "SELECT * FROM " + TABLE_SUBJECTS + " WHERE " + Subjects_ID + " = " + subject_id;
    } else if (subject_name != null) {
        query = "SELECT * FROM " + TABLE_SUBJECTS + " WHERE " + Subjects_Name + " = '" + subject_name + "'";
    } else {
        Log.d(TAG, "getSubject error: Not found subject");
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.NOT_FOUND_SUBJECT));
    }
    return getSubjectByQuery(query, db);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:27,代碼來源:DBHelper.java

示例5: deleteSubject

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * Delete a subject
 *
 * @param subject_id subject id
 * @return DATABASE_CODE
 */
public DATABASE_CODE deleteSubject(@Nonnegative int subject_id) {
    SQLiteDatabase db;
    try {
        db = this.getWritableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "deleteSubject error: " + e.toString());
        return DATABASE_CODE.CONNECT_FAIL;
    }

    String whereClause = Subjects_ID + " = " + subject_id;

    if (db.delete(TABLE_SUBJECTS, whereClause, null) != 0) {
        Log.d(TAG, "deleteSubject success");
        return DATABASE_CODE.DELETE_SUBJECT_SUCCESS;
    }
    Log.d(TAG, "deleteSubject error");
    return DATABASE_CODE.DELETE_SUBJECT_FAIL;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:25,代碼來源:DBHelper.java

示例6: getRepeat

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * @param repeat_id   Integer
 * @param repeat_name String
 * @return Repeat
 * @throws NullObjectException if connect to database fail or not found repeat
 */
public Repeat getRepeat(@Nonnegative Integer repeat_id, String repeat_name) throws NullObjectException {
    SQLiteDatabase db;
    try {
        db = this.getReadableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "getRepeat error: " + e.toString());
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.CONNECT_FAIL));
    }
    String query;
    if (repeat_id != null) {
        query = "SELECT *  FROM " + TABLE_REPEAT + " WHERE " + Repeat_ID + " = " + repeat_id;
    } else if (repeat_name != null) {
        query = "SELECT *  FROM " + TABLE_REPEAT + " WHERE " + Repeat_Name + " = '" + repeat_name + "'";
    } else {
        Log.d(TAG, "getRepeat error: Not found repeat");
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.NOT_FOUND_REPEAT));
    }
    return getRepeatByQuery(query, db);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:26,代碼來源:DBHelper.java

示例7: getLocation

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * @param location_id   Integer
 * @param location_name Integer
 * @return Location
 * @throws NullObjectException if connect to database fail or not found location
 */
public Location getLocation(@Nonnegative Integer location_id, String location_name) throws NullObjectException {
    SQLiteDatabase db;
    try {
        db = this.getReadableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "getLocation error: " + e.toString());
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.CONNECT_FAIL));
    }

    String selectQuery;
    if (location_id != null) {
        selectQuery = "SELECT *  FROM " + TABLE_LOCATION + " WHERE " + Location_ID + " = " + location_id;
    } else if (location_name != null) {
        selectQuery = "SELECT *  FROM " + TABLE_LOCATION + " WHERE " + Location_Name + " = '" + location_name + "'";
    } else {
        Log.d(TAG, "getLocation error: Not found location");
        throw new NullObjectException(mDBStringHelper.getDBString(DATABASE_CODE.NOT_FOUND_LOCATION));
    }
    return getLocationByQuery(selectQuery, db);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:27,代碼來源:DBHelper.java

示例8: deleteLocation

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * @param location_id location_id
 * @return {@link DATABASE_CODE#CONNECT_FAIL},{@link DATABASE_CODE#DELETE_LOCATION_SUCCESS},{@link DATABASE_CODE#DELETE_LOCATION_FAIL}
 */
public DATABASE_CODE deleteLocation(@Nonnegative int location_id) {
    SQLiteDatabase db;
    try {
        db = this.getWritableDatabase();
    } catch (SQLiteException e) {
        Log.d(TAG, "deleteLocation error: " + e.toString());
        return DATABASE_CODE.CONNECT_FAIL;
    }

    String whereClause = Location_ID + " = " + location_id;

    //Deleting a record
    if (db.delete(TABLE_LOCATION, whereClause, null) != 0) {
        Log.d(TAG, "deleteLocation success");
        return DATABASE_CODE.DELETE_LOCATION_SUCCESS;
    }
    Log.d(TAG, "deleteLocation error");
    return DATABASE_CODE.DELETE_LOCATION_FAIL;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:24,代碼來源:DBHelper.java

示例9: EventParent

import javax.annotation.Nonnegative; //導入依賴的package包/類
public EventParent(int event_parent_id, int repeat_id, @Nonnegative int event_parent_day_start, @Nonnegative int event_parent_day_end) {
    if (event_parent_id > 0) {
        this.event_parent_id = event_parent_id;
    } else {
        this.event_parent_id = Constant.INT_NONE_VALUE;
    }
    if (repeat_id > 0) {
        this.repeat_id = repeat_id;
    } else {
        this.repeat_id = Constant.INT_NONE_VALUE;
    }
    if (event_parent_day_start >= 0) {
        this.event_parent_day_start = event_parent_day_start;
    } else {
        this.event_parent_day_start = 0;
    }
    if (event_parent_day_end >= this.event_parent_day_start) {
        this.event_parent_day_end = event_parent_day_end;
    } else {
        this.event_parent_day_end = this.event_parent_day_start;
    }
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:23,代碼來源:EventParent.java

示例10: WeekLesson

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * Full params constructor
 */
public WeekLesson(int week_lesson_id, @Nonnull String subject_id, int repeat_id, @Nonnegative int week_lesson_day_start,
                  @Nonnegative int week_lesson_day_end, @Nonnegative int week_lesson_day_index) {
    if (week_lesson_id > 0) {
        this.week_lesson_id = week_lesson_id;
    } else {
        this.week_lesson_id = Constant.INT_NONE_VALUE;
    }
    this.subject_id = subject_id;
    if (repeat_id > 0) {
        this.repeat_id = repeat_id;
    } else {
        this.repeat_id = Constant.INT_NONE_VALUE;
    }
    if (week_lesson_day_start >= 0) {
        this.week_lesson_day_start = week_lesson_day_start;
    }else {
        this.week_lesson_day_start = 0;
    }
    if (!(week_lesson_day_end >= this.week_lesson_day_start)) {
        this.week_lesson_day_end = week_lesson_day_end;
    }else {
        this.week_lesson_day_end = this.week_lesson_day_start;
    }
    if (week_lesson_day_index >= Calendar.SUNDAY && week_lesson_day_index <= Calendar.SATURDAY) {
        this.week_lesson_day_index = week_lesson_day_index;
    }
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:31,代碼來源:WeekLesson.java

示例11: Event

import javax.annotation.Nonnegative; //導入依賴的package包/類
public Event(long event_id, @Nullable Integer location_id, int event_parent_id, @Nonnull String event_tittle, @Nonnull String event_content,
             int event_text_color, int event_background_color, @Nonnegative int event_ts_start, @Nonnegative int event_ts_end,
             @Nonnegative int event_ts_remind, @Nonnull EventType event_type, @Nonnull EventStatus event_status,
             @Nonnull String event_status_reason_change, @Nonnull String event_account_sync) {
    super(event_id, location_id, event_tittle, event_content, event_text_color, event_background_color, event_ts_start, event_ts_end, event_ts_remind,
            event_status, event_status_reason_change, event_type, String.valueOf(Constant.INT_NONE_VALUE));
    if (event_parent_id > 0) {
        String parent_id = String.valueOf(event_parent_id);
        setDraw_item_parent_id(parent_id);
    }
    if(!EventType.isEventNormal(event_type)){
        setDraw_item_type(EventType.EVENT,this);
    }
    this.event_account_sync = event_account_sync;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:16,代碼來源:Event.java

示例12: Subject

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * Full params constructor to get item from database
 */
public Subject(@Nonnull String subject_id, @Nullable String teacher_id, @Nonnull String subject_name, int subject_text_color,
               int subject_background_color, @Nonnegative int subject_day_start, @Nonnegative int subject_day_end,
               @Nonnull String subject_content, @Nonnull String subject_background) {
    this.subject_id = subject_id;
    this.teacher_id = teacher_id;
    this.subject_name = subject_name;
    this.subject_text_color = subject_text_color;
    this.subject_background_color = subject_background_color;
    if (subject_day_start >= 0) {
        this.subject_day_start = subject_day_start;
    } else {
        this.subject_day_start = 0;
    }
    if (subject_day_end >= this.subject_day_start) {
        this.subject_day_end = subject_day_end;
    } else {
        this.subject_day_end = this.subject_day_start;
    }
    this.subject_content = subject_content;
    this.subject_background = subject_background;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:25,代碼來源:Subject.java

示例13: of

import javax.annotation.Nonnegative; //導入依賴的package包/類
/**
 * Creates a new {@link Scheme} instance.
 *
 * @param n the number of parts to produce (must be {@code >1})
 * @param k the threshold of joinable parts (must be {@code <= n})
 * @return an {@code N}/{@code K} {@link Scheme}
 */
@CheckReturnValue
public static Scheme of(@Nonnegative int n, @Nonnegative int k) {
  checkArgument(k > 1, "K must be > 1");
  checkArgument(n >= k, "N must be >= K");
  checkArgument(n <= 255, "N must be <= 255");
  return new AutoValue_Scheme(n, k);
}
 
開發者ID:codahale,項目名稱:shamir,代碼行數:15,代碼來源:Scheme.java

示例14: ActionCompletedEvent

import javax.annotation.Nonnegative; //導入依賴的package包/類
public ActionCompletedEvent( @Nonnull final String name,
                             final boolean tracked,
                             @Nonnull final Object[] parameters,
                             final boolean returnsResult,
                             @Nullable final Object result,
                             @Nullable final Throwable throwable,
                             @Nonnegative final long duration )
{
  assert duration >= 0;
  assert null == throwable || null == result;
  _name = Objects.requireNonNull( name );
  _tracked = tracked;
  _parameters = Objects.requireNonNull( parameters );
  _returnsResult = returnsResult;
  _result = result;
  _throwable = throwable;
  _duration = duration;
}
 
開發者ID:arez,項目名稱:arez,代碼行數:19,代碼來源:ActionCompletedEvent.java

示例15: doFetch

import javax.annotation.Nonnegative; //導入依賴的package包/類
protected final FluentFuture<List<T>> doFetch(
    final @Nullable Constraints.ConstraintHost criteria,
    final Constraints.Constraint ordering,
    final Constraints.Constraint exclusion,
    final @Nonnegative int skip,
    final @Nonnegative int limit) {
  return submit(new Callable<List<T>>() {
    @SuppressWarnings("resource")
    @Override
    public List<T> call() throws Exception {
      @Nullable Bson query = criteria != null ? convertToBson(criteria) : null;

      FindIterable<T> cursor = collection().find(query);

      if (!exclusion.isNil()) {
        cursor.projection(convertToBson(exclusion));
      }

      if (!ordering.isNil()) {
        cursor.sort(convertToBson(ordering));
      }

      cursor.skip(skip);

      if (limit != 0) {
        cursor.limit(limit);
        if (limit <= LARGE_BATCH_SIZE) {
          // if limit specified and is smaller than reasonable large batch size
          // then we force batch size to be the same as limit,
          // but negative, this force cursor to close right after result is sent
          cursor.batchSize(-limit);
        }
      }

      return ImmutableList.copyOf(cursor);
    }
  });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:Repositories.java


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