rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -44,7 +44,7 @@ impl BoundingBox {
let leftUnspecified = topLeft.is_none() || bottomLeft.is_none();
let rightUnspecified = topRight.is_none() || bottomRight.is_none();
if leftUnspecified && rightUnspecified {
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
}
let newTopLeft;
@@ -53,21 +53,21 @@ impl BoundingBox {
let newBottomRight;
if leftUnspecified {
newTopRight = topRight.ok_or(Exceptions::illegalStateEmpty())?;
newBottomRight = bottomRight.ok_or(Exceptions::illegalStateEmpty())?;
newTopRight = topRight.ok_or(Exceptions::illegalState)?;
newBottomRight = bottomRight.ok_or(Exceptions::illegalState)?;
newTopLeft = RXingResultPoint::new(0.0, newTopRight.getY());
newBottomLeft = RXingResultPoint::new(0.0, newBottomRight.getY());
} else if rightUnspecified {
newTopLeft = topLeft.ok_or(Exceptions::illegalStateEmpty())?;
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalStateEmpty())?;
newTopLeft = topLeft.ok_or(Exceptions::illegalState)?;
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalState)?;
newTopRight = RXingResultPoint::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
newBottomRight =
RXingResultPoint::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
} else {
newTopLeft = topLeft.ok_or(Exceptions::illegalStateEmpty())?;
newTopRight = topRight.ok_or(Exceptions::illegalStateEmpty())?;
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalStateEmpty())?;
newBottomRight = bottomRight.ok_or(Exceptions::illegalStateEmpty())?;
newTopLeft = topLeft.ok_or(Exceptions::illegalState)?;
newTopRight = topRight.ok_or(Exceptions::illegalState)?;
newBottomLeft = bottomLeft.ok_or(Exceptions::illegalState)?;
newBottomRight = bottomRight.ok_or(Exceptions::illegalState)?;
}
Ok(BoundingBox {
@@ -102,19 +102,13 @@ impl BoundingBox {
rightBox: Option<BoundingBox>,
) -> Result<BoundingBox, Exceptions> {
if leftBox.is_none() {
return Ok(rightBox
.as_ref()
.ok_or(Exceptions::illegalStateEmpty())?
.clone());
return Ok(rightBox.as_ref().ok_or(Exceptions::illegalState)?.clone());
}
if rightBox.is_none() {
return Ok(leftBox
.as_ref()
.ok_or(Exceptions::illegalStateEmpty())?
.clone());
return Ok(leftBox.as_ref().ok_or(Exceptions::illegalState)?.clone());
}
let leftBox = leftBox.ok_or(Exceptions::illegalStateEmpty())?;
let rightBox = rightBox.ok_or(Exceptions::illegalStateEmpty())?;
let leftBox = leftBox.ok_or(Exceptions::illegalState)?;
let rightBox = rightBox.ok_or(Exceptions::illegalState)?;
BoundingBox::new(
leftBox.image,