Skip to content

Commit

Permalink
Small cleanup, e.g. reduce commons-lang usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Thopap committed Dec 2, 2023
1 parent f596528 commit 62fe083
Show file tree
Hide file tree
Showing 76 changed files with 405 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core;

import java.util.Objects;

import org.apache.commons.lang3.Validate;
import org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode;
import org.openehealth.ipf.commons.ihe.xds.core.responses.Severity;
Expand All @@ -37,9 +39,9 @@ public XdsRuntimeException(
String location)
{
super();
this.errorCode = Validate.notNull(errorCode);
this.errorCode = Objects.requireNonNull(errorCode);
this.codeContext = Validate.notEmpty(codeContext);
this.severity = Validate.notNull(severity);
this.severity = Objects.requireNonNull(severity);
this.location = location;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.audit;

import org.openehealth.ipf.commons.audit.codes.EventOutcomeIndicator;
import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Document;
import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Status;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2009 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,7 +15,7 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

import lombok.experimental.Delegate;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
Expand All @@ -27,23 +27,22 @@
*/
public class EbXMLAdhocQueryRequest30 implements EbXMLAdhocQueryRequest {
private final AdhocQueryRequest request;

/**
* Constructs the wrapper using the real object.
* @param request
* the ebXML 3.0 object.
*/
public EbXMLAdhocQueryRequest30(AdhocQueryRequest request) {
notNull(request, "request cannot be null");
this.request = request;
this.request = requireNonNull(request, "request cannot be null");;
}

@Override
public String getReturnType() {
var responseOption = request.getResponseOption();
return responseOption != null ? responseOption.getReturnType() : null;
}

@Override
public void setReturnType(String returnType) {
request.getResponseOption().setReturnType(returnType);
Expand All @@ -53,7 +52,7 @@ public void setReturnType(String returnType) {
public String getId() {
return request.getAdhocQuery().getId();
}

@Override
public void setId(String id) {
request.getAdhocQuery().setId(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import java.util.UUID;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

/**
* Encapsulation of {@link ClassificationType}.
Expand All @@ -37,7 +37,7 @@ public class EbXMLClassification30 implements EbXMLClassification {
* the object to wrap.
*/
public EbXMLClassification30(ClassificationType classification) {
notNull(classification, "classification cannot be null");
requireNonNull(classification, "classification cannot be null");
classification.setObjectType(CLASSIFICATION_OBJECT_TYPE);
this.classification = classification;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLExternalIdentifier;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLInternationalString;
Expand All @@ -33,7 +33,7 @@ public class EbXMLExternalIdentifier30 implements EbXMLExternalIdentifier {
* the object to wrap.
*/
public EbXMLExternalIdentifier30(ExternalIdentifierType externalIdentifierType) {
notNull(externalIdentifierType, "externalIdentifierType cannot be null");
requireNonNull(externalIdentifierType, "externalIdentifierType cannot be null");
externalIdentifierType.setObjectType(EXTERNAL_IDENTIFIER_OBJECT_TYPE);
externalIdentifier = externalIdentifierType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2009 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -75,14 +75,14 @@ public LocalizedString getLocalizedString(int idx) {
if (localizedEbRS30 == null) {
return null;
}

return createLocalizedString(localizedEbRS30);
}

@Override
public List<LocalizedString> getLocalizedStrings() {
if (international == null) {
return Collections.emptyList();
return Collections.emptyList();
}

var list = international.getLocalizedString();
Expand All @@ -98,10 +98,10 @@ public LocalizedString getSingleLocalizedString() {
}

var locals = international.getLocalizedString();
if (locals == null || locals.size() == 0) {
if (locals == null || locals.isEmpty()) {
return null;
}

return createLocalizedString(locals.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2009 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,7 +15,7 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -37,10 +37,9 @@ public class EbXMLNonconstructiveDocumentSetRequest30<T extends RetrieveDocument
* the object to wrap.
*/
public EbXMLNonconstructiveDocumentSetRequest30(T request) {
notNull(request, "request cannot be null");
this.request = request;
this.request = requireNonNull(request, "request cannot be null");;
}

@Override
public T getInternal() {
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import static org.apache.commons.lang3.Validate.noNullElements;
import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.*;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.*;

Expand Down Expand Up @@ -57,7 +57,7 @@ protected void fillObjectLibrary() {
* the object library to use.
*/
EbXMLObjectContainer30(EbXMLObjectLibrary objectLibrary) {
notNull(objectLibrary, "objLibrary cannot be null");
requireNonNull(objectLibrary, "objLibrary cannot be null");
this.objectLibrary = objectLibrary;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public List<EbXMLExtrinsicObject> getExtrinsicObjects() {

@Override
public List<EbXMLRegistryPackage> getRegistryPackages(String classificationNode) {
notNull(classificationNode, "classificationNode cannot be null");
requireNonNull(classificationNode, "classificationNode cannot be null");

var acceptedIds = getAcceptedIds(classificationNode);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2009 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,7 +15,7 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -48,8 +48,7 @@ public class EbXMLProvideAndRegisterDocumentSetRequest30 extends EbXMLObjectCont
*/
public EbXMLProvideAndRegisterDocumentSetRequest30(ProvideAndRegisterDocumentSetRequestType request, EbXMLObjectLibrary objectLibrary) {
super(objectLibrary);
notNull(request, "request cannot be null");
this.request = request;
this.request = requireNonNull(request, "request cannot be null");;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.apache.commons.lang3.Validate.notNull;
import static java.util.Objects.requireNonNull;

/**
* Encapsulation of {@link AdhocQueryResponse}.
Expand All @@ -48,7 +48,7 @@ public class EbXMLQueryResponse30 extends EbXMLObjectContainer30 implements EbXM
*/
public EbXMLQueryResponse30(AdhocQueryResponse response, EbXMLObjectLibrary objectLibrary) {
super(objectLibrary);
notNull(response, "response cannot be null");
requireNonNull(response, "response cannot be null");
this.response = response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30;

import org.apache.commons.lang3.Validate;
import static java.util.Objects.requireNonNull;

import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRegistryError;
import org.openehealth.ipf.commons.ihe.xds.core.responses.Severity;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryError;
Expand All @@ -27,8 +28,7 @@ public class EbXMLRegistryError30 implements EbXMLRegistryError {
private final RegistryError error;

public EbXMLRegistryError30(RegistryError error) {
Validate.notNull(error, "registry error object cannot be null");
this.error = error;
this.error = requireNonNull(error, "registry error object cannot be null");;
}

@Override
Expand Down
Loading

0 comments on commit 62fe083

Please sign in to comment.