[OLINGO-1191]Code improvements
This commit is contained in:
parent
ac02329d1f
commit
3344e05b34
|
@ -203,7 +203,7 @@ public class AsyncRequestWrapperImpl<R extends ODataResponse> extends AbstractRe
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// wait for retry-after
|
// wait for retry-after
|
||||||
Thread.sleep(retryAfter * 1000);
|
Thread.sleep((long)retryAfter * 1000);
|
||||||
} catch (InterruptedException ignore) {
|
} catch (InterruptedException ignore) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.client.core.communication.request.batch;
|
package org.apache.olingo.client.core.communication.request.batch;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.apache.commons.io.LineIterator;
|
import org.apache.commons.io.LineIterator;
|
||||||
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
import org.apache.olingo.client.api.communication.request.batch.ODataBatchLineIterator;
|
||||||
|
|
||||||
|
@ -63,6 +65,9 @@ public class ODataBatchLineIteratorImpl implements ODataBatchLineIterator {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String next() {
|
public String next() {
|
||||||
|
if(!hasNext()){
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
return nextLine();
|
return nextLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,17 +134,16 @@ public final class ServiceDocumentImpl implements ServiceDocument {
|
||||||
if (title != null ? !title.equals(that.title) : that.title != null) {
|
if (title != null ? !title.equals(that.title) : that.title != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (entitySets != null ? !entitySets.equals(that.entitySets) : that.entitySets != null) {
|
if (!entitySets.equals(that.entitySets)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (functionImports != null ? !functionImports.equals(that.functionImports) : that.functionImports != null) {
|
if (!functionImports.equals(that.functionImports)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (singletons != null ? !singletons.equals(that.singletons) : that.singletons != null) {
|
if (!singletons.equals(that.singletons)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (relatedServiceDocuments != null ?
|
if (!relatedServiceDocuments.equals(that.relatedServiceDocuments)) {
|
||||||
!relatedServiceDocuments.equals(that.relatedServiceDocuments) : that.relatedServiceDocuments != null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(metadata != null ? !metadata.equals(that.metadata) : that.metadata != null);
|
return !(metadata != null ? !metadata.equals(that.metadata) : that.metadata != null);
|
||||||
|
@ -154,10 +153,10 @@ public final class ServiceDocumentImpl implements ServiceDocument {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = title != null ? title.hashCode() : 0;
|
int result = title != null ? title.hashCode() : 0;
|
||||||
result = 31 * result + (entitySets != null ? entitySets.hashCode() : 0);
|
result = 31 * result + (entitySets.hashCode());
|
||||||
result = 31 * result + (functionImports != null ? functionImports.hashCode() : 0);
|
result = 31 * result + (functionImports.hashCode());
|
||||||
result = 31 * result + (singletons != null ? singletons.hashCode() : 0);
|
result = 31 * result + (singletons.hashCode());
|
||||||
result = 31 * result + (relatedServiceDocuments != null ? relatedServiceDocuments.hashCode() : 0);
|
result = 31 * result + (relatedServiceDocuments.hashCode());
|
||||||
result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
|
result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class ClientCollectionValueImpl<OV extends ClientValue> extends AbstractC
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((values == null) ? 0 : values.hashCode());
|
result = prime * result + (values.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,10 +207,10 @@ public class ClientComplexValueImpl extends AbstractClientValue implements Clien
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((annotations == null) ? 0 : annotations.hashCode());
|
result = prime * result + (annotations.hashCode());
|
||||||
result = prime * result + ((associationLinks == null) ? 0 : associationLinks.hashCode());
|
result = prime * result + (associationLinks.hashCode());
|
||||||
result = prime * result + ((fields == null) ? 0 : fields.hashCode());
|
result = prime * result + (fields.hashCode());
|
||||||
result = prime * result + ((navigationLinks == null) ? 0 : navigationLinks.hashCode());
|
result = prime * result + (navigationLinks.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class ClientDeltaImpl extends ClientEntitySetImpl implements ClientDelta
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((addedLinks == null) ? 0 : addedLinks.hashCode());
|
result = prime * result + (addedLinks.hashCode());
|
||||||
result = prime * result + ((deletedEntities == null) ? 0 : deletedEntities.hashCode());
|
result = prime * result + (deletedEntities.hashCode());
|
||||||
result = prime * result + ((deletedLinks == null) ? 0 : deletedLinks.hashCode());
|
result = prime * result + (deletedLinks.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,13 +112,11 @@ public abstract class ODataLibraryException extends ODataException {
|
||||||
|
|
||||||
private ODataErrorMessage buildMessage(final ResourceBundle bundle, final Locale locale) {
|
private ODataErrorMessage buildMessage(final ResourceBundle bundle, final Locale locale) {
|
||||||
String message = null;
|
String message = null;
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Formatter f = new Formatter(builder, locale);
|
||||||
try {
|
try {
|
||||||
message = bundle.getString(getClass().getSimpleName() + '.' + messageKey.getKey());
|
message = bundle.getString(getClass().getSimpleName() + '.' + messageKey.getKey());
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
Formatter f = new Formatter(builder, locale);
|
|
||||||
f.format(message, parameters);
|
f.format(message, parameters);
|
||||||
f.close();
|
|
||||||
Locale usedLocale = bundle.getLocale();
|
Locale usedLocale = bundle.getLocale();
|
||||||
if (Locale.ROOT.equals(usedLocale)) {
|
if (Locale.ROOT.equals(usedLocale)) {
|
||||||
usedLocale = DEFAULT_LOCALE;
|
usedLocale = DEFAULT_LOCALE;
|
||||||
|
@ -129,6 +127,8 @@ public abstract class ODataLibraryException extends ODataException {
|
||||||
} catch (MissingFormatArgumentException e) {
|
} catch (MissingFormatArgumentException e) {
|
||||||
return new ODataErrorMessage("Missing replacement for place holder in message '" + message +
|
return new ODataErrorMessage("Missing replacement for place holder in message '" + message +
|
||||||
"' for following arguments '" + Arrays.toString(parameters) + "'!", DEFAULT_LOCALE);
|
"' for following arguments '" + Arrays.toString(parameters) + "'!", DEFAULT_LOCALE);
|
||||||
|
}finally{
|
||||||
|
f.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue