Small refactoring + additional classes

Signed-off-by: Stanislav Trailov <Stanislav.Trailov@bosch.io>
This commit is contained in:
Stanislav Trailov
2023-06-29 12:29:40 +03:00
parent e7226e3933
commit 0d4f67e345
5 changed files with 139 additions and 8 deletions

View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2023 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Describing the fields of the Tag model which can be used in the REST API e.g.
* for sorting etc.
* Additionally here were added fields for DistributionSet in order
* filtering over distribution set fields also.
*/
public enum DistributionSetTagFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The controllerId field.
*/
COLOUR("colour"),
/**
*
*/
DISTRIBUTIONSET("assignedToDistributionSet",
DistributionSetFields.ID.getFieldName(), DistributionSetFields.NAME.getFieldName());
private final String fieldName;
private final List<String> subEntityAttributes;
private DistributionSetTagFields(final String fieldName) {
this.fieldName = fieldName;
this.subEntityAttributes = Collections.emptyList();
}
private DistributionSetTagFields(final String fieldName, final String... subEntityAttributes) {
this.fieldName = fieldName;
this.subEntityAttributes = Arrays.asList(subEntityAttributes);
}
@Override
public List<String> getSubEntityAttributes() {
return Collections.unmodifiableList(subEntityAttributes);
}
@Override
public String getFieldName() {
return fieldName;
}
}

View File

@@ -0,0 +1,69 @@
/**
* Copyright (c) 2023 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Describing the fields of the Tag model which can be used in the REST API e.g.
* for sorting etc.
* Additionally here were added fields for Target in order
* filtering over target fields also.
*/
public enum TargetTagFields implements FieldNameProvider {
/**
* The id field.
*/
ID("id"),
/**
* The name field.
*/
NAME("name"),
/**
* The description field.
*/
DESCRIPTION("description"),
/**
* The controllerId field.
*/
COLOUR("colour"),
/**
*
*/
TARGET("assignedToTargets",
TargetFields.ID.getFieldName(), TargetFields.NAME.getFieldName());
private final String fieldName;
private final List<String> subEntityAttributes;
private TargetTagFields(final String fieldName) {
this.fieldName = fieldName;
this.subEntityAttributes = Collections.emptyList();
}
private TargetTagFields(final String fieldName, final String... subEntityAttributes) {
this.fieldName = fieldName;
this.subEntityAttributes = Arrays.asList(subEntityAttributes);
}
@Override
public List<String> getSubEntityAttributes() {
return Collections.unmodifiableList(subEntityAttributes);
}
@Override
public String getFieldName() {
return fieldName;
}
}