本文整理汇总了Java中com.fernandocejas.arrow.checks.Preconditions类的典型用法代码示例。如果您正苦于以下问题:Java Preconditions类的具体用法?Java Preconditions怎么用?Java Preconditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Preconditions类属于com.fernandocejas.arrow.checks包,在下文中一共展示了Preconditions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: filter
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Returns the elements of {@code unfiltered} that satisfy a predicate.
*/
public static <T> UnmodifiableIterator<T> filter(
final Iterator<T> unfiltered, final Predicate<? super T> predicate) {
Preconditions.checkNotNull(unfiltered);
Preconditions.checkNotNull(predicate);
return new AbstractIterator<T>() {
@Override
protected T computeNext() {
while (unfiltered.hasNext()) {
T element = unfiltered.next();
if (predicate.apply(element)) {
return element;
}
}
return endOfData();
}
};
}
开发者ID:android10,项目名称:arrow,代码行数:21,代码来源:Iterators.java
示例2: execute
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Executes the current use case.
*
* @param observer {@link DisposableObserver} which will be listening to the observable build
* by {@link #buildUseCaseObservable(Params)} ()} method.
* @param params Parameters (Optional) used to build/execute this use case.
*/
public void execute(DisposableObserver<T> observer, Params params) {
Preconditions.checkNotNull(observer);
final Observable<T> observable = this.buildUseCaseObservable(params)
.subscribeOn(Schedulers.from(threadExecutor))
.observeOn(postExecutionThread.getScheduler());
addDisposable(observable.subscribeWith(observer));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:UseCase.java
示例3: execute
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Executes the current use case.
*
* @param observer {@link DisposableObserver} which will be listening to the observable build by
* {@link #buildUseCaseObservable(Params)} ()} method.
* @param params Parameters (Optional) used to build/execute this use case.
*/
public void execute(DisposableObserver<T> observer, Params params) {
Preconditions.checkNotNull(observer);
final Observable<T> observable = this.buildUseCaseObservable(params)
.subscribeOn(Schedulers.from(threadExecutor))
.observeOn(postExecutionThread.getScheduler());
addDisposable(observable.subscribeWith(observer));
}
开发者ID:oantajames,项目名称:clean-news,代码行数:15,代码来源:UseCase.java
示例4: performSearch
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Perform search based on param
*
* @param term
*/
public void performSearch(String term) {
Preconditions.checkNotNull(disposables);
disposables.add(
dataManager.getSearchResults(term)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(subscription -> getMvpView().showSearchInProgress())
.subscribeWith(new DisposableSubscriber<SearchDefinition>() {
@Override
public void onNext(SearchDefinition searchDefinition) {
getMvpView().showSearchDefinition(term, searchDefinition);
}
@Override
public void onError(Throwable t) {
handleRequestError(t, "performSearch()");
}
@Override
public void onComplete() {
// Not used
}
})
);
}
开发者ID:teeeeeegz,项目名称:DuckDuckDefine-Android,代码行数:32,代码来源:SearchPresenter.java
示例5: currentLoadType
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
private UserSubscription currentLoadType() {
final Bundle arguments = getArguments();
if (arguments != null) {
Preconditions.checkNotNull(arguments, "Fragment arguments cannot be null");
return Parcels.unwrap(arguments.getParcelable(ARGS_USER_SUBSCRIPTION));
}
return new UserSubscription();
}
开发者ID:riteshakya037,项目名称:Subs,代码行数:9,代码来源:CreateSubscriptionFragment.java
示例6: currentLoadType
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
private SubscriptionType currentLoadType() {
final Bundle arguments = getArguments();
if (arguments != null) {
Preconditions.checkNotNull(arguments, "Fragment arguments cannot be null");
return SubscriptionType.valueOf(arguments.getString(ARGS_LOAD_TYPE));
}
return SubscriptionType.ALL;
}
开发者ID:riteshakya037,项目名称:Subs,代码行数:9,代码来源:SubscriptionListFragment.java
示例7: execute
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Executes the current use case.
*
* @param observer {@link DisposableObserver} which will be listening to the observable build
* by {@link #buildUseCaseObservable(Params)} ()} method.
* @param params Parameters (Optional) used to build/execute this use case.
*/
public Disposable execute(DisposableObserver<T> observer, Params params) {
Preconditions.checkNotNull(observer);
final Observable<T> observable = this.buildUseCaseObservable(params)
.subscribeOn(Schedulers.from(threadExecutor))
.observeOn(postExecutionThread.getScheduler());
return observable.subscribeWith(observer);
}
开发者ID:riteshakya037,项目名称:Subs,代码行数:15,代码来源:UseCase.java
示例8: Car
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
private Car(String brand, String model, String registrationNumber) {
Preconditions.checkNotNull(brand);
Preconditions.checkNotNull(model);
this.brand = brand;
this.model = model;
this.registrationNumber = Optional.fromNullable(registrationNumber);
}
开发者ID:android10,项目名称:java-code-examples,代码行数:8,代码来源:UseCaseScenario01.java
示例9: removeIf
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Removes every element that satisfies the provided predicate from the
* iterator. The iterator will be left exhausted: its {@code hasNext()}
* method will return {@code false}.
*
* @param removeFrom the iterator to (potentially) remove elements from
* @param predicate a predicate that determines whether an element should
* be removed
* @return {@code true} if any elements were removed from the iterator
* @since 2.0
*/
public static <T> boolean removeIf(
Iterator<T> removeFrom, Predicate<? super T> predicate) {
Preconditions.checkNotNull(predicate);
boolean modified = false;
while (removeFrom.hasNext()) {
if (predicate.apply(removeFrom.next())) {
removeFrom.remove();
modified = true;
}
}
return modified;
}
开发者ID:android10,项目名称:arrow,代码行数:24,代码来源:Iterators.java
示例10: addAll
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Adds all elements in {@code iterator} to {@code collection}. The iterator
* will be left exhausted: its {@code hasNext()} method will return
* {@code false}.
*
* @return {@code true} if {@code collection} was modified as a result of this
* operation
*/
public static <T> boolean addAll(Collection<T> addTo, Iterator<? extends T> iterator) {
Preconditions.checkNotNull(addTo);
Preconditions.checkNotNull(iterator);
boolean wasModified = false;
while (iterator.hasNext()) {
wasModified |= addTo.add(iterator.next());
}
return wasModified;
}
开发者ID:android10,项目名称:arrow,代码行数:18,代码来源:Iterators.java
示例11: partitionImpl
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
private static <T> UnmodifiableIterator<List<T>> partitionImpl(
final Iterator<T> iterator, final int size, final boolean pad) {
Preconditions.checkNotNull(iterator);
Preconditions.checkArgument(size > 0);
return new UnmodifiableIterator<List<T>>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public List<T> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Object[] array = new Object[size];
int count = 0;
for (; count < size && iterator.hasNext(); count++) {
array[count] = iterator.next();
}
for (int i = count; i < size; i++) {
array[i] = null; // for GWT
}
@SuppressWarnings("unchecked") // we only put Ts in it
List<T> list = Collections.unmodifiableList(
(List<T>) Arrays.asList(array));
return pad || count == size ? list : list.subList(0, count);
}
};
}
开发者ID:android10,项目名称:arrow,代码行数:32,代码来源:Iterators.java
示例12: all
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Returns {@code true} if every element returned by {@code iterator}
* satisfies the given predicate. If {@code iterator} is empty, {@code true}
* is returned.
*/
public static <T> boolean all(Iterator<T> iterator, Predicate<? super T> predicate) {
Preconditions.checkNotNull(predicate);
while (iterator.hasNext()) {
T element = iterator.next();
if (!predicate.apply(element)) {
return false;
}
}
return true;
}
开发者ID:android10,项目名称:arrow,代码行数:16,代码来源:Iterators.java
示例13: advance
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Calls {@code next()} on {@code iterator}, either {@code numberToAdvance} times
* or until {@code hasNext()} returns {@code false}, whichever comes first.
*
* @return the number of elements the iterator was advanced
* @since 13.0 (since 3.0 as {@code Iterators.skip})
*/
public static int advance(Iterator<?> iterator, int numberToAdvance) {
Preconditions.checkNotNull(iterator);
Preconditions.checkArgument(numberToAdvance >= 0, "numberToAdvance must be nonnegative");
int i;
for (i = 0; i < numberToAdvance && iterator.hasNext(); i++) {
iterator.next();
}
return i;
}
开发者ID:android10,项目名称:arrow,代码行数:18,代码来源:Iterators.java
示例14: clear
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Clears the iterator using its remove method.
*/
static void clear(Iterator<?> iterator) {
Preconditions.checkNotNull(iterator);
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
}
}
开发者ID:android10,项目名称:arrow,代码行数:11,代码来源:Iterators.java
示例15: currentUserId
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Get current user id from fragments arguments.
*/
private int currentUserId() {
final Bundle arguments = getArguments();
Preconditions.checkNotNull(arguments, "Fragment arguments cannot be null");
return arguments.getInt(PARAM_USER_ID);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:UserDetailsFragment.java
示例16: addDisposable
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
/**
* Dispose from current {@link CompositeDisposable}.
*/
private void addDisposable(Disposable disposable) {
Preconditions.checkNotNull(disposable);
Preconditions.checkNotNull(disposables);
disposables.add(disposable);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:UseCase.java
示例17: buildUseCaseObservable
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
@Override Observable<User> buildUseCaseObservable(Params params) {
Preconditions.checkNotNull(params);
return this.userRepository.user(params.userId);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:GetUserDetails.java
示例18: execute
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
public void execute(Params params, DisposableSubscriber<T> subscriber) {
Preconditions.checkNotNull(subscriber);
final Flowable<T> flowable = this.buildUseCaseObservable(params);
addDisposable(flowable.subscribeWith(subscriber));
}
开发者ID:crazysunj,项目名称:CrazyDaily,代码行数:6,代码来源:UseCase.java
示例19: addDisposable
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
private void addDisposable(Disposable disposable) {
Preconditions.checkNotNull(disposable);
Preconditions.checkNotNull(mDisposables);
mDisposables.add(disposable);
}
开发者ID:crazysunj,项目名称:CrazyDaily,代码行数:6,代码来源:UseCase.java
示例20: onAttach
import com.fernandocejas.arrow.checks.Preconditions; //导入依赖的package包/类
@Override
public void onAttach(final Context pContext) {
AndroidSupportInjection.inject(this);
super.onAttach(pContext);
Preconditions.checkNotNull(dateFormatter, "Field dateFormatter is null, did you miss to inject it with your dependency injection mechanism?");
}
开发者ID:RoRoche,项目名称:AndroidModularReloaded,代码行数:7,代码来源:FragmentSecond.java
注:本文中的com.fernandocejas.arrow.checks.Preconditions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论