forked from eclipse-leshan/leshan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not do type conversion at encoding time by default anymore.
- Loading branch information
1 parent
5e344d3
commit 680ee7d
Showing
9 changed files
with
71 additions
and
115 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
43 changes: 43 additions & 0 deletions
43
leshan-core/src/main/java/org/eclipse/leshan/core/node/codec/LwM2mValueChecker.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,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
* | ||
* Contributors: | ||
* Sierra Wireless - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.leshan.core.node.codec; | ||
|
||
import org.eclipse.leshan.core.model.ResourceModel.Type; | ||
import org.eclipse.leshan.core.node.LwM2mPath; | ||
|
||
/** | ||
* A {@link LwM2mValueConverter} which do no conversion but raise a {@link CodecException} if type is not the expected | ||
* one. | ||
* | ||
*/ | ||
public class LwM2mValueChecker implements LwM2mValueConverter { | ||
|
||
@Override | ||
public Object convertValue(Object value, Type currentType, Type expectedType, LwM2mPath resourcePath) { | ||
if (expectedType == null) { | ||
// unknown resource, trusted value | ||
return value; | ||
} | ||
|
||
if (currentType == expectedType) { | ||
// expected type | ||
return value; | ||
} | ||
|
||
throw new CodecException("Invalid value type for resource %s, expected %s, got %s", resourcePath, expectedType, | ||
currentType); | ||
} | ||
} |
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
91 changes: 0 additions & 91 deletions
91
leshan-core/src/test/java/org/eclipse/leshan/core/node/codec/Lwm2mValueConverterTest.java
This file was deleted.
Oops, something went wrong.
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
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