当前位置: 首页>>代码示例>>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;未经允许,请勿转载。