-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metric Advisor: Replace reflection based private field setting with h…
…elper pattern (#16781)
- Loading branch information
Showing
42 changed files
with
1,519 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...java/com/azure/ai/metricsadvisor/implementation/util/AnomalyAlertConfigurationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) AutoRest Code Generator. | ||
|
||
package com.azure.ai.metricsadvisor.implementation.util; | ||
|
||
import com.azure.ai.metricsadvisor.models.AnomalyAlertConfiguration; | ||
|
||
/** | ||
* The helper class to set the non-public properties of an {@link AnomalyAlertConfiguration} instance. | ||
*/ | ||
public final class AnomalyAlertConfigurationHelper { | ||
private static AnomalyAlertConfigurationAccessor accessor; | ||
|
||
private AnomalyAlertConfigurationHelper() { } | ||
|
||
/** | ||
* Type defining the methods to set the non-public properties of an {@link AnomalyAlertConfiguration} instance. | ||
*/ | ||
public interface AnomalyAlertConfigurationAccessor { | ||
void setId(AnomalyAlertConfiguration configuration, String id); | ||
} | ||
|
||
/** | ||
* The method called from {@link AnomalyAlertConfiguration} to set it's accessor. | ||
* | ||
* @param configurationAccessor The accessor. | ||
*/ | ||
public static void setAccessor(final AnomalyAlertConfigurationAccessor configurationAccessor) { | ||
accessor = configurationAccessor; | ||
} | ||
|
||
static void setId(AnomalyAlertConfiguration configuration, String id) { | ||
accessor.setId(configuration, id); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../com/azure/ai/metricsadvisor/implementation/util/AnomalyDetectionConfigurationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.ai.metricsadvisor.implementation.util; | ||
|
||
import com.azure.ai.metricsadvisor.models.AnomalyDetectionConfiguration; | ||
|
||
/** | ||
* The helper class to set the non-public properties of an {@link AnomalyDetectionConfiguration} instance. | ||
*/ | ||
public final class AnomalyDetectionConfigurationHelper { | ||
private static AnomalyDetectionConfigurationAccessor accessor; | ||
|
||
private AnomalyDetectionConfigurationHelper() { } | ||
|
||
/** | ||
* Type defining the methods to set the non-public properties of an {@link AnomalyDetectionConfiguration} instance. | ||
*/ | ||
public interface AnomalyDetectionConfigurationAccessor { | ||
void setId(AnomalyDetectionConfiguration configuration, String id); | ||
void setMetricId(AnomalyDetectionConfiguration configuration, String metricId); | ||
} | ||
|
||
/** | ||
* The method called from {@link AnomalyDetectionConfiguration} to set it's accessor. | ||
* | ||
* @param configurationAccessor The accessor. | ||
*/ | ||
public static void setAccessor(final AnomalyDetectionConfigurationAccessor configurationAccessor) { | ||
accessor = configurationAccessor; | ||
} | ||
|
||
static void setId(AnomalyDetectionConfiguration configuration, String id) { | ||
accessor.setId(configuration, id); | ||
} | ||
|
||
static void setMetricId(AnomalyDetectionConfiguration configuration, String metricId) { | ||
accessor.setMetricId(configuration, metricId); | ||
} | ||
} | ||
|
75 changes: 75 additions & 0 deletions
75
...sadvisor/src/main/java/com/azure/ai/metricsadvisor/implementation/util/AnomalyHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.ai.metricsadvisor.implementation.util; | ||
|
||
import com.azure.ai.metricsadvisor.models.Anomaly; | ||
import com.azure.ai.metricsadvisor.models.AnomalyStatus; | ||
import com.azure.ai.metricsadvisor.models.DimensionKey; | ||
import com.azure.ai.metricsadvisor.models.Severity; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
/** | ||
* The helper class to set the non-public properties of an {@link Anomaly} instance. | ||
*/ | ||
public final class AnomalyHelper { | ||
private static AnomalyAccessor accessor; | ||
|
||
private AnomalyHelper() { } | ||
|
||
/** | ||
* Type defining the methods to set the non-public properties of an {@link Anomaly} instance. | ||
*/ | ||
public interface AnomalyAccessor { | ||
void setMetricId(Anomaly anomaly, String metricId); | ||
void setSeriesKey(Anomaly anomaly, DimensionKey seriesKey); | ||
void setDetectionConfigurationId(Anomaly anomaly, String detectionConfigurationId); | ||
void setSeverity(Anomaly anomaly, Severity severity); | ||
void setStatus(Anomaly anomaly, AnomalyStatus status); | ||
void setTimeStamp(Anomaly anomaly, OffsetDateTime timeStamp); | ||
void setCreatedTime(Anomaly anomaly, OffsetDateTime createdTime); | ||
void setModifiedTime(Anomaly anomaly, OffsetDateTime modifiedTime); | ||
} | ||
|
||
/** | ||
* The method called from {@link Anomaly} to set it's accessor. | ||
* | ||
* @param anomalyAccessor The accessor. | ||
*/ | ||
public static void setAccessor(final AnomalyAccessor anomalyAccessor) { | ||
accessor = anomalyAccessor; | ||
} | ||
|
||
static void setMetricId(Anomaly anomaly, String metricId) { | ||
accessor.setMetricId(anomaly, metricId); | ||
} | ||
|
||
static void setSeriesKey(Anomaly anomaly, DimensionKey seriesKey) { | ||
accessor.setSeriesKey(anomaly, seriesKey); | ||
} | ||
|
||
static void setDetectionConfigurationId(Anomaly anomaly, String detectionConfigurationId) { | ||
accessor.setDetectionConfigurationId(anomaly, detectionConfigurationId); | ||
} | ||
|
||
static void setSeverity(Anomaly anomaly, Severity severity) { | ||
accessor.setSeverity(anomaly, severity); | ||
} | ||
|
||
static void setStatus(Anomaly anomaly, AnomalyStatus status) { | ||
accessor.setStatus(anomaly, status); | ||
} | ||
|
||
static void setTimeStamp(Anomaly anomaly, OffsetDateTime timeStamp) { | ||
accessor.setTimeStamp(anomaly, timeStamp); | ||
} | ||
|
||
static void setCreatedTime(Anomaly anomaly, OffsetDateTime createdTime) { | ||
accessor.setCreatedTime(anomaly, createdTime); | ||
} | ||
|
||
static void setModifiedTime(Anomaly anomaly, OffsetDateTime modifiedTime) { | ||
accessor.setModifiedTime(anomaly, modifiedTime); | ||
} | ||
} |
Oops, something went wrong.